Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RahulSDeshpande/d0e2b36fec297291cd0e to your computer and use it in GitHub Desktop.
Save RahulSDeshpande/d0e2b36fec297291cd0e to your computer and use it in GitHub Desktop.
public class MyAsyncTask extends AsyncTask<Void, Void, Cursor> {
@Override
protected Cursor doInBackground(Void... params) {
DatabaseHelper helper = new DatabaseHelper(MainActivity.this);
return helper.getReadableDatabase().rawQuery("SELECT * FROM myTable", null);
}
@Override
protected void onPostExecute(Cursor cursor) {
super.onPostExecute(cursor);
Toast.makeText(
MainActivity.this,
"Count: " + cursor.getCount(),
Toast.LENGTH_SHORT
).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment