android.widget.SimpleCursorAdapter Java Examples
The following examples show how to use
android.widget.SimpleCursorAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmsListActivity.java From SmsScheduler with GNU General Public License v2.0 | 7 votes |
private SimpleCursorAdapter getSmsListAdapter() { SimpleCursorAdapter adapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_2, DbHelper.getDbHelper(this).getCursor(), new String[] { DbHelper.COLUMN_MESSAGE, DbHelper.COLUMN_RECIPIENT_NAME }, new int[] { android.R.id.text1, android.R.id.text2 } ); adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex) { TextView textView = (TextView) view; if (textView.getId() == android.R.id.text2) { textView.setText(getFormattedSmsInfo(cursor)); return true; } return false; } }); return adapter; }
Example #2
Source File: DisplayActivity.java From coursera-android with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get Account information // Must have a Google account set up on your device mAccountList = AccountManager.get(this).getAccountsByType("com.google"); mType = mAccountList[0].type; mName = mAccountList[0].name; // Insert new contacts insertAllNewContacts(); // Create and set empty list adapter mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, null, columnsToDisplay, resourceIds, 0); setListAdapter(mAdapter); // Initialize a CursorLoader getLoaderManager().initLoader(0, null, this); }
Example #3
Source File: MyListActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Cursor mCursor = getContacts(); startManagingCursor(mCursor); // Now create a new list adapter bound to the cursor. // SimpleListAdapter is designed for binding to a Cursor. ListAdapter adapter = new SimpleCursorAdapter(this, // Context. android.R.layout.simple_list_item_2, // Specify the row template // to use (here, two // columns bound to the // two retrieved cursor // rows). mCursor, // Pass in the cursor to bind to. // Array of cursor columns to bind to. new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }, // Array of layout variables to bind to new int[] { android.R.id.text1, android.R.id.text2 }); // Bind to our new adapter. setListAdapter(adapter); }
Example #4
Source File: ShowBookmarks.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // We select the id, the URL and the title from the database // the ID is handy for the reaction on the selection String[] selection = { Browser.BookmarkColumns._ID, Browser.BookmarkColumns.URL, Browser.BookmarkColumns.TITLE }; String[] displayFields = { Browser.BookmarkColumns.URL, Browser.BookmarkColumns.TITLE }; int[] viewFields = { android.R.id.text1, android.R.id.text2 }; Cursor cursor = managedQuery(Browser.BOOKMARKS_URI, selection, null, null, null); startManagingCursor(cursor); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, displayFields, viewFields); setListAdapter(adapter); }
Example #5
Source File: LoaderThrottle.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setEmptyText("No data. Select 'Populate' to fill with data from Z to A at a rate of 4 per second."); setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { MainTable.COLUMN_NAME_DATA }, new int[] { android.R.id.text1 }, 0); setListAdapter(mAdapter); // Start out with a progress indicator. setListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }
Example #6
Source File: List7.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_7); mPhone = (TextView) findViewById(R.id.phone); getListView().setOnItemSelectedListener(this); // Get a cursor with all numbers. // This query will only return contacts with phone numbers Cursor c = getContentResolver().query(Phone.CONTENT_URI, PHONE_PROJECTION, Phone.NUMBER + " NOT NULL", null, null); startManagingCursor(c); ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view android.R.layout.simple_list_item_1, // Give the cursor to the list adapter c, // Map the DISPLAY_NAME column to... new String[] {Phone.DISPLAY_NAME}, // The "text1" view defined in the XML template new int[] {android.R.id.text1}); setListAdapter(adapter); }
Example #7
Source File: List2.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get a cursor with all people Cursor c = getContentResolver().query(Contacts.CONTENT_URI, CONTACT_PROJECTION, null, null, null); startManagingCursor(c); ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view android.R.layout.simple_list_item_1, // Give the cursor to the list adatper c, // Map the NAME column in the people database to... new String[] {Contacts.DISPLAY_NAME}, // The "text1" view defined in the XML template new int[] {android.R.id.text1}); setListAdapter(adapter); }
Example #8
Source File: VmMigrateActivity.java From moVirt with Apache License 2.0 | 6 votes |
private void setLoader(final String filterClusterId, final String filterHostId) { hostsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_activated_1, null, new String[]{OVirtContract.Host.NAME}, new int[]{android.R.id.text1}, 0); cursorAdapterLoader = new CursorAdapterLoader(hostsAdapter) { @Override public synchronized Loader<Cursor> onCreateLoader(int id, Bundle args) { return provider.query(Host.class) .where(Host.STATUS, HostStatus.UP.toString()) .where(Host.CLUSTER_ID, filterClusterId) .where(Host.ID, filterHostId, Relation.NOT_EQUAL).asLoader(); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { hostsAdapter.swapCursor(data); if (data != null && data.getCount() > 0) { enableViews(); } } }; getSupportLoaderManager().initLoader(HOSTS_LOADER, null, cursorAdapterLoader); }
Example #9
Source File: Gallery2.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery_2); // Get a cursor with all people Cursor c = getContentResolver().query(Contacts.CONTENT_URI, CONTACT_PROJECTION, null, null, null); startManagingCursor(c); SpinnerAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view android.R.layout.simple_gallery_item, // Give the cursor to the list adatper c, // Map the NAME column in the people database to... new String[] {Contacts.DISPLAY_NAME}, // The "text1" view defined in the XML template new int[] { android.R.id.text1 }); Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(adapter); }
Example #10
Source File: LoaderCursor.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Give some text to display if there is no data. In a real // application this would come from a resource. setEmptyText("No phone numbers"); // We have a menu item to show in action bar. setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, null, new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS }, new int[] { android.R.id.text1, android.R.id.text2 }, 0); setListAdapter(mAdapter); // Start out with a progress indicator. setListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }
Example #11
Source File: NoteListActivity.java From MyOwnNotes with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") private void showAndFillListView() { makeSureSqlDatabaseIsOpen(); String[] from = { NotesTable.CLOUMN_CONTENT, NotesTable.COLUMN_STATUS }; int[] to = {R.id.textview_note_row_content, R.id.textview_note_row_marked }; simpleCursorAdapter = new SimpleCursorAdapter(this, R.layout.note_listview_row, null, from, to); if(loaderManager.getLoader(1) != null) { loaderManager.destroyLoader(1); } loaderManager.initLoader(1, null, this); setListAdapter(simpleCursorAdapter); }
Example #12
Source File: PopupActivity.java From ankihelper with GNU General Public License v3.0 | 6 votes |
private void setActAdapter(IDictionary dict) { Object adapter = dict.getAutoCompleteAdapter(PopupActivity.this, android.R.layout.simple_spinner_dropdown_item); if(adapter != null){ if(adapter instanceof SimpleCursorAdapter){ act.setAdapter((SimpleCursorAdapter) adapter); } else if(adapter instanceof UrbanAutoCompleteAdapter){ act.setAdapter((UrbanAutoCompleteAdapter) adapter); } } act.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if(hasFocus){ if(act.getText().toString().trim().isEmpty()){ return; } act.showDropDown(); } } } ); }
Example #13
Source File: UserInfoActivity.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null); db = helper.getWritableDatabase(); daoMaster = new DaoMaster(db); daoSession = daoMaster.newSession(); userInfoDao = daoSession.getNoteDao(); String textColumn = UserInfoDao.Properties.Text.columnName; String orderBy = textColumn + " COLLATE LOCALIZED ASC"; cursor = db.query(userInfoDao.getTablename(), userInfoDao.getAllColumns(), null, null, null, null, orderBy); String[] from = { textColumn, UserInfoDao.Properties.Comment.columnName }; int[] to = { android.R.id.text1, android.R.id.text2 }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, from, to); setListAdapter(adapter); editTextName = (EditText) findViewById(R.id.editTextName); editTextAge = (EditText) findViewById(R.id.editTextAge); addUiListeners(); }
Example #14
Source File: SearchView.java From Search_Layout with MIT License | 6 votes |
/** * 关注1 * 模糊查询数据 & 显示到ListView列表上 */ private void queryData(String tempName) { // 1. 模糊搜索 Cursor cursor = helper.getReadableDatabase().rawQuery( "select id as _id,name from records where name like '%" + tempName + "%' order by id desc ", null); // 2. 创建adapter适配器对象 & 装入模糊搜索的结果 adapter = new SimpleCursorAdapter(context, android.R.layout.simple_list_item_1, cursor, new String[] { "name" }, new int[] { android.R.id.text1 }, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); // 3. 设置适配器 listView.setAdapter(adapter); adapter.notifyDataSetChanged(); System.out.println(cursor.getCount()); // 当输入框为空 & 数据库中有搜索记录时,显示 "删除搜索记录"按钮 if (tempName.equals("") && cursor.getCount() != 0){ tv_clear.setVisibility(VISIBLE); } else { tv_clear.setVisibility(INVISIBLE); }; }
Example #15
Source File: ProceduresList.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * {@inheritDoc} */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Uri uri = getIntent().getData(); if (uri == null) { uri = Procedures.CONTENT_URI; } sync(this, uri); Cursor cursor = managedQuery(uri, PROJECTION2, null, null, Procedures.DEFAULT_SORT_ORDER); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.procedure_list_row, cursor, new String[]{ Procedures.Contract.TITLE, Procedures.Contract.VERSION //Procedures.Contract.AUTHOR }, new int[]{ R.id.toptext, R.id.bottomtext }); Locales.updateLocale(this, getString(R.string.force_locale)); setListAdapter(adapter); }
Example #16
Source File: MainActivity.java From Smartlab with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] columns = { android.provider.MediaStore.Audio.Albums._ID, android.provider.MediaStore.Audio.Albums.ALBUM }; cursor = managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, columns, null, null, null); String[] displayFields = new String[] { MediaStore.Audio.Albums.ALBUM }; int[] displayViews = new int[] { android.R.id.text1 }; setListAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, displayFields, displayViews)); }
Example #17
Source File: CursorFragment.java From V.FlyoutTest with MIT License | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Give some text to display if there is no data. In a real // application this would come from a resource. setEmptyText("No phone numbers"); // We have a menu item to show in action bar. setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2, null, new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS }, new int[] { android.R.id.text1, android.R.id.text2 }, 0); setListAdapter(mAdapter); // Start out with a progress indicator. setListShown(false); // Prepare the loader. Either re-connect with an existing one, // or start a new one. getLoaderManager().initLoader(0, null, this); }
Example #18
Source File: AccessControl3NotesActivity.java From diva-android with GNU General Public License v3.0 | 6 votes |
public void accessNotes(View view) { EditText pinTxt = (EditText) findViewById(R.id.aci3notesPinText); Button abutton = (Button) findViewById(R.id.aci3naccessbutton); SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this); String pin = spref.getString(getString(R.string.pkey), ""); String userpin = pinTxt.getText().toString(); // XXX Easter Egg? if (userpin.equals(pin)) { // Display the private notes ListView lview = (ListView) findViewById(R.id.aci3nlistView); Cursor cr = getContentResolver().query(NotesProvider.CONTENT_URI, new String[] {"_id", "title", "note"}, null, null, null); String[] columns = {NotesProvider.C_TITLE, NotesProvider.C_NOTE}; int [] fields = {R.id.title_entry, R.id.note_entry}; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.notes_entry ,cr, columns, fields, 0); lview.setAdapter(adapter); pinTxt.setVisibility(View.INVISIBLE); abutton.setVisibility(View.INVISIBLE); //cr.close(); } else { Toast.makeText(this, "Please Enter a valid pin!", Toast.LENGTH_SHORT).show(); } }
Example #19
Source File: DatabaseExampleActivity.java From coursera-android with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Create a new DatabaseHelper mDbHelper = new DatabaseOpenHelper(this); // start with an empty database clearAll(); // Insert records insertArtists(); // Create a cursor mCursor = readArtists(); mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, mCursor, DatabaseOpenHelper.columns, new int[] { R.id._id, R.id.name }, 0); setListAdapter(mAdapter); }
Example #20
Source File: ContactsOpsImpl.java From mobilecloud-15 with Apache License 2.0 | 6 votes |
/** * Hook method dispatched by the GenericActivity framework to * initialize the ContactsOpsImpl object after it's been created. * * @param view The currently active ContactsOps.View. * @param firstTimeIn Set to "true" if this is the first time the * Ops class is initialized, else set to * "false" if called after a runtime * configuration change. */ public void onConfiguration(ContactsOps.View view, boolean firstTimeIn) { // Create a WeakReference to the ContactsOps.View. mContactsView = new WeakReference<>(view); if (firstTimeIn) { // Initialize the Google account information. initializeAccount(); // Initialize the SimpleCursorAdapter. mCursorAdapter = new SimpleCursorAdapter(view.getApplicationContext(), R.layout.list_layout, null, sColumnsToDisplay, sColumnResIds, 1); } }
Example #21
Source File: DisplayActivity.java From coursera-android with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get Account information Account[] mAccountList = AccountManager.get(this).getAccountsByType("com.google"); // Must have a Google account set up on your device if (mAccountList.length == 0) finish(); mType = mAccountList[0].type; mName = mAccountList[0].name; // Insert new contacts insertAllNewContacts(); // Create and set empty list adapter mAdapter = new SimpleCursorAdapter(this, R.layout.list_layout, null, columnsToDisplay, resourceIds, 0); setListAdapter(mAdapter); // Initialize a CursorLoader getLoaderManager().initLoader(0, null, this); }
Example #22
Source File: ExampleActivity.java From CPOrm with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_example); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //deleteDatabase(new MyCPOrmConfiguration().getDatabaseName()); adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, null, new String[]{"user_name"}, new int[]{android.R.id.text1}, 0); listview = (ListView) findViewById(R.id.listView); listview.setAdapter(adapter); getLoaderManager().initLoader(1, Bundle.EMPTY, this); new PopulateDataTask(this).execute(); }
Example #23
Source File: ContactListFragment.java From CSCI4669-Fall15-Android with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setRetainInstance(true); // save fragment across config changes setHasOptionsMenu(true); // this fragment has menu items to display // set text to display when there are no contacts setEmptyText(getResources().getString(R.string.no_contacts)); // get ListView reference and configure ListView contactListView = getListView(); contactListView.setOnItemClickListener(viewContactListener); contactListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // map each contact's name to a TextView in the ListView layout String[] from = new String[] { "name" }; int[] to = new int[] { android.R.id.text1 }; contactAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, from, to, 0); setListAdapter(contactAdapter); // set adapter that supplies data }
Example #24
Source File: ContactListFragment.java From CSCI4669-Fall15-Android with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setRetainInstance(true); // save fragment across config changes setHasOptionsMenu(true); // this fragment has menu items to display // set text to display when there are no contacts setEmptyText(getResources().getString(R.string.no_contacts)); // get ListView reference and configure ListView contactListView = getListView(); contactListView.setOnItemClickListener(viewContactListener); contactListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); // map each contact's name to a TextView in the ListView layout String[] from = new String[] { "name" }; int[] to = new int[] { android.R.id.text1 }; contactAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, from, to, 0); setListAdapter(contactAdapter); // set adapter that supplies data }
Example #25
Source File: TaskListFragment.java From SimplePomodoro-android with MIT License | 6 votes |
void refreshView() { TaskLocalUtils tLocalUtils = new TaskLocalUtils(GlobalContext.getInstance()); cr = tLocalUtils.getAllCursorInMainList(); mTitles = getAllTitlesOfCurosr(cr); mIds = getAllIdFromCursor(cr); // final TaskListCursorAdapter mAdapter = new TaskListCursorAdapter(getActivity(), R.layout.my_task_list, // cr, // new String[] { TaskRecorder.KEY_TITLE }, // new int[] { R.id.tvLarger }, 2, getFragmentManager(), this); final SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.my_task_list, cr, new String[] { TaskRecorder.KEY_TITLE }, new int[] { R.id.tvLarger }); listView.setAdapter(mAdapter); }
Example #26
Source File: StatsAppWidgetConfigure.java From callmeter with GNU General Public License v3.0 | 6 votes |
/** * Set {@link SimpleCursorAdapter} for {@link Spinner}. */ private void setAdapter() { final Cursor c = getContentResolver().query(DataProvider.Plans.CONTENT_URI, PROJ_ADAPTER, DataProvider.Plans.WHERE_PLANS, null, DataProvider.Plans.NAME); String[] fieldName; if (cbShowShortname.isChecked()) { fieldName = new String[]{DataProvider.Plans.SHORTNAME}; } else { fieldName = new String[]{DataProvider.Plans.NAME}; } final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, fieldName, new int[]{android.R.id.text1}); final int pos = spinner.getSelectedItemPosition(); spinner.setAdapter(adapter); if (pos >= 0 && pos < spinner.getCount()) { spinner.setSelection(pos); } }
Example #27
Source File: StudentsList.java From android with GNU General Public License v2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.students_list, container, false); db = new Database(getActivity()); // Obtiene el cursor con el listado de alumnos de la Base de Datos Cursor cursor = db.getStudents(); SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), R.layout.student_row, cursor, FROM_SHOW, TO, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); ListView lvStudentsList = (ListView) view.findViewById(R.id.lvStudentsList); lvStudentsList.setAdapter(adapter); return view; }
Example #28
Source File: TodosOverviewActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
private void fillData() { // Fields from the database (projection) // Must include the _id column for the adapter to work String[] from = new String[] { TodoTable.COLUMN_SUMMARY }; // Fields on the UI to which we map int[] to = new int[] { R.id.label }; getLoaderManager().initLoader(0, null, this); adapter = new SimpleCursorAdapter(this, R.layout.todo_row, null, from, to, 0); setListAdapter(adapter); }
Example #29
Source File: CustomContactProviderDemo.java From coursera-android with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ContentResolver contentResolver = getContentResolver(); ContentValues values = new ContentValues(); // Insert first record values.put(DataContract.DATA, "Record1"); Uri firstRecordUri = contentResolver.insert(DataContract.CONTENT_URI, values); values.clear(); // Insert second record values.put(DataContract.DATA, "Record2"); contentResolver.insert(DataContract.CONTENT_URI, values); values.clear(); // Insert third record values.put(DataContract.DATA, "Record3"); contentResolver.insert(DataContract.CONTENT_URI, values); // Delete first record contentResolver.delete(firstRecordUri, null, null); // Create and set cursor and list adapter Cursor c = contentResolver.query(DataContract.CONTENT_URI, null, null, null, null); setListAdapter(new SimpleCursorAdapter(this, R.layout.list_layout, c, DataContract.ALL_COLUMNS, new int[] { R.id.idString, R.id.data }, 0)); }
Example #30
Source File: TodosOverviewActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
private void fillData() { // Fields from the database (projection) // Must include the _id column for the adapter to work String[] from = new String[] { TodoTable.COLUMN_SUMMARY }; // Fields on the UI to which we map int[] to = new int[] { R.id.label }; getLoaderManager().initLoader(0, null, this); adapter = new SimpleCursorAdapter(this, R.layout.todo_row, null, from, to, 0); setListAdapter(adapter); }