petdance/bobby-tables

Android examples

Opened this issue · 1 comments

4a-j commented

I don't know whether you'd want to list it under "Java" or "Android" -- I note that you have both "C#" and ".NET" -- but the platform provides its own database API.

The object you're running queries against can be either a ContentResolver:

Cursor result = contentResolver.query(uri, projection, selection, args, orderBy);

or an SQLiteDatabase object:

Cursor result = database.query(table, projection, selection, args, groupBy, having, orderBy);

In either case, your selection string should contain question marks, which are bound to the args array from left to right, as in this example:

static final String my_table = "users";
static final String[] my_projection = new String[] { "username", "last_login" };
String checkdate = "2015-11-01";
Cursor result = object.query(my_table, my_projection, "date(last_login) < date(?)", new String[] { checkdate }, null, null, null);

Excellent, thank you.