Forked from dmitry-zaitsev/Executing SQLite queries in background (example for article)
Last active
August 29, 2015 14:13
-
-
Save RahulSDeshpande/d0e2b36fec297291cd0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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