Using the content provider

Lucas edited this page Mar 20, 2014 · 6 revisions

Note You must override the default identity column as specified here ( before the following will work:

	mySpinner.setAdapter(new SimpleCursorAdapter(getActivity(),
		new String[] { "MyProperty" },
		new int[] { },
	getActivity().getSupportLoaderManager().initLoader(0, null, new LoaderCallbacks<Cursor>() {
		public Loader<Cursor> onCreateLoader(int arg0, Bundle cursor) {
			return new CursorLoader(getActivity(),
				ContentProvider.createUri(MyEntityClass.class, null),
				null, null, null, null
		public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
		public void onLoaderReset(Loader<Cursor> arg0) {

You must also have the following provider in your AndroidManifest.xml:

<application ...>
    <provider android:authorities="com.example" android:exported="false" android:name="com.activeandroid.content.ContentProvider" />
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.