Created
April 22, 2017 09:15
-
-
Save markojerkic/8c6625bb3b3116973fdf8e37014b5f01 to your computer and use it in GitHub Desktop.
Read method of CRUD
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 void read (DatabaseHelper mDbHelper) { | |
SQLiteDatabase db = mDbHelper.getReadableDatabase(); | |
// Define which rows you want to query | |
String[] projection = { | |
FeedEntry._ID, | |
FeedEntry.COLUMN_NAME1, | |
FeedEntry.COLUMN_NAME2 | |
}; | |
// Filter results WHERE "title" = 'My Title' | |
String selection = FeedEntry.COLUMN_NAME1 + " = ?"; | |
String[] selectionArgs = { "Name of the table" }; | |
// How you want the results sorted in the resulting Cursor | |
String sortOrder = | |
FeedEntry.COLUMN_NAME_SUBTITLE + " DESC"; | |
Cursor cursor = db.query( | |
FeedEntry.TABLE_NAME, // The table to query | |
projection, // The columns to return | |
selection, // The columns for the WHERE clause | |
selectionArgs, // The values for the WHERE clause | |
null, // don't group the rows | |
null, // don't filter by row groups | |
sortOrder // The sort order | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment