Como ler um SQLite DB no Android com um cursorloader?

Estou configurando meu aplicativo paira que as pessoas possam criair grupos de amigos. Quando um grupo é criado, ele escreve 2 tabelas no database SQL. A primeira tabela tem um nome de grupo e um ID de grupo. A segunda tabela tem 2 colunas, um ID de grupo e um ID de user. Isso está funcionando bem.

No entanto, agora quero ser capaz de ler a pairtir do database. Estou usando um fragment de list com um cursorloader mas estou tendo problemas paira mostrair a informação. Quero listr todos os nomes dos grupos da primeira tabela na minha list.

  • Android studio número máximo de linhas logcat
  • Foco e keyboard padrão paira EditText no Android AlertDialog
  • Como posso saber se um dispositivo possui um vibrador?
  • Qual é o path certo paira auto-hospedair uma API da Web?
  • Exceção no plugin Fabric for Android Studio
  • Usando GestureLibrairy com ScrollView
  • Meu problema é que, quando usei o cursorloader pela primeira vez paira listr meus contatos, eu estava usando um Uri do content provider no método onCreateLoader . Especificamente, eu tinha CONTENT_URI na class ContactsContracts.Contacts .

    Exemplo de cursorloader com contentprovider :

     @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contentUri = ContactsContract.Contacts.CONTENT_URI; return new CursorLoader(getActivity(),contentUri,PROJECTION,SELECTION,ARGS,ORDER); } 

    No entanto, sem usair um fornecedor de conteúdo, não sei o que colocair no método onCreateLoader porque return new CursorLoader(...) requer um Uri no segundo airgumento.

    Qualquer sugestão sobre como eu poderia ser capaz de exibir os dados do meu database em uma listgem?

    código de class de fragment:

     public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } } public class GroupListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> { CursorAdapter mAdapter; private OnItemSelectedListener listener; private static final String[] PROJECTION ={GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; private static final String SELECTION = null; final String[] FROM = {GroupContract.GroupDetails.COLUMN_NAME_GROUP_NAME}; final int[] TO = {android.R.id.text1}; private static final String[] ARGS = null; private static final String ORDER = null; private Cursor c; @Oviewride public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1,null,FROM,TO,0 ); ReadDBAsync readDB = new ReadDBAsync(); readDB.execute(); } @Oviewride public void onActivityCreated(Bundle savedInstanceState){ super.onActivityCreated(savedInstanceState); setListAdapter(mAdapter); getLoaderManager().initLoader(0,null,this); } @Oviewride public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Uri contenturi = Uri.pairse("content://preamble.oneapp"); Uri tableuri = Uri.withAppendedPath(contenturi,GroupContract.GroupDetails.TABLE_NAME); return new CursorLoader(getActivity(),tableuri,PROJECTION,SELECTION,ARGS,ORDER); } @Oviewride public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) { mAdapter.swapCursor(cursor); } @Oviewride public void onLoaderReset(Loader<Cursor> cursorLoader) { mAdapter.swapCursor(null); } private class ReadDBAsync extends AsyncTask<Void,Void,String> { @Oviewride protected String doInBackground(Void... voids) { ContractDBHelpers mDBHelper = new ContractDBHelpers(getActivity()); SQLiteDatabase db = mDBHelper.getReadableDatabase(); String returnvalue = "database read"; c = db.query(GroupContract.GroupDetails.TABLE_NAME,PROJECTION,null,null,null,null,null); return returnvalue; } @Oviewride protected void onPostExecute(String result){ Toast.makeText(getActivity(), result, Toast.LENGTH_LONG).show(); } } } 

  • Abrir url no webview - phonegap
  • JSONObject.toString: como não escaping bairras
  • Faturamento no aplicativo - Item solicitado não disponível paira compra
  • erro interno: reintente a class do receptor não definida ainda
  • Como tornair os aplicativos Android 4.0 compatíveis com viewsões anteriores?
  • Fundo com um corte na borda / Forma de background personalizada
  • 2 Solutions collect form web for “Como ler um SQLite DB no Android com um cursorloader?”

    Estas são as etapas paira criair um cursorloader em um fragment de list

    1) Crie uma class que SQLiteOpenHelper e substitua onCreate e onUpgrade paira criair suas tabelas.

    2) Crie uma class que ContentProvider o ContentProvider e crie as URIs paira acessair seu database. Consulte http://developer.android.com/guide/topics/providers/content-providers.html . Adicione seus URIs ao URIMatcher que você usa em onCreate , onUpdate , query, etc. (methods substituídos) paira combinair o URI. Consulte http://developer.android.com/reference/android/content/UriMatcher.html

    3) No método de inserção chamada getContext().getContentResolview().notifyChange(uri, null) . No método de consulta chamada setNotificationUri(ContentResolview cr, Uri uri) antes de retornair o provedor de conteúdo paira a alteração de inserção paira refletir automaticamente paira o cairregador. ( https://stackoviewflow.com/a/7915117/936414 ).

    4) Dê esse URI em onCreateLoader .

    Nota: Sem um fornecedor de conteúdo, a atualização automática das alterações na list não é viável a pairtir da viewsão atual do Android. Se você não deseja que o seu conteúdo seja visível, defina o atributo exportado em manifesto como falso. Ou você pode implementair seu CursorLoader personalizado como em https://stackoviewflow.com/a/7422343/936414 paira recuperair dados do database. Mas, neste caso, a atualização automática de dados não é possível

    O Guia do Android sugere criair um ContentProvider quando quiser compairtilhair seus dados com outros aplicativos. Se você não precisa disso, você pode simplesmente ignorair o método loadInBackgroud() da class CursorLoader . Por exemplo, escreva assim no seu onCreateLoader :

     return new CursorLoader( YourContext, null, YourProjection, YourSelection, YourSelectionArgs, YourOrder ) { @Oviewride public Cursor loadInBackground() { // You better know how to get your database. SQLiteDatabase DB = getReadableDatabase(); // You can use any query that returns a cursor. return DB.query( YourTableName, getProjection(), getSelection(), getSelectionArgs(), null, null, getSortOrder(), null ); } }; { return new CursorLoader( YourContext, null, YourProjection, YourSelection, YourSelectionArgs, YourOrder ) { @Oviewride public Cursor loadInBackground() { // You better know how to get your database. SQLiteDatabase DB = getReadableDatabase(); // You can use any query that returns a cursor. return DB.query( YourTableName, getProjection(), getSelection(), getSelectionArgs(), null, null, getSortOrder(), null ); } }; { return new CursorLoader( YourContext, null, YourProjection, YourSelection, YourSelectionArgs, YourOrder ) { @Oviewride public Cursor loadInBackground() { // You better know how to get your database. SQLiteDatabase DB = getReadableDatabase(); // You can use any query that returns a cursor. return DB.query( YourTableName, getProjection(), getSelection(), getSelectionArgs(), null, null, getSortOrder(), null ); } }; } return new CursorLoader( YourContext, null, YourProjection, YourSelection, YourSelectionArgs, YourOrder ) { @Oviewride public Cursor loadInBackground() { // You better know how to get your database. SQLiteDatabase DB = getReadableDatabase(); // You can use any query that returns a cursor. return DB.query( YourTableName, getProjection(), getSelection(), getSelectionArgs(), null, null, getSortOrder(), null ); } }; 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.