use of android.database.sqlite.SQLiteQueryBuilder in project aware-client by denzilferreira.
the class Locations_Provider method query.
/**
* Query entries from the database
*/
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
initialiseDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(sUriMatcher.match(uri)) {
case LOCATIONS:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(locationsProjectionMap);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
try {
Cursor c = qb.query(database, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
} catch (IllegalStateException e) {
if (Aware.DEBUG)
Log.e(Aware.TAG, e.getMessage());
return null;
}
}
use of android.database.sqlite.SQLiteQueryBuilder in project aware-client by denzilferreira.
the class Network_Provider method query.
/**
* Query entries from the database
*/
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
initialiseDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(sUriMatcher.match(uri)) {
case NETWORK:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(networkProjectionMap);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
try {
Cursor c = qb.query(database, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
} catch (IllegalStateException e) {
if (Aware.DEBUG)
Log.e(Aware.TAG, e.getMessage());
return null;
}
}
use of android.database.sqlite.SQLiteQueryBuilder in project aware-client by denzilferreira.
the class Proximity_Provider method query.
/**
* Query entries from the database
*/
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
initialiseDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(sUriMatcher.match(uri)) {
case SENSOR_DEV:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(sensorMap);
break;
case SENSOR_DATA:
qb.setTables(DATABASE_TABLES[1]);
qb.setProjectionMap(sensorDataMap);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
try {
Cursor c = qb.query(database, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
} catch (IllegalStateException e) {
if (Aware.DEBUG)
Log.e(Aware.TAG, e.getMessage());
return null;
}
}
use of android.database.sqlite.SQLiteQueryBuilder in project aware-client by denzilferreira.
the class Rotation_Provider method query.
/**
* Query entries from the database
*/
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
initialiseDatabase();
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(sUriMatcher.match(uri)) {
case SENSOR_DEV:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(sensorMap);
break;
case SENSOR_DATA:
qb.setTables(DATABASE_TABLES[1]);
qb.setProjectionMap(sensorDataMap);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
try {
Cursor c = qb.query(database, projection, selection, selectionArgs, null, null, sortOrder);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
} catch (IllegalStateException e) {
if (Aware.DEBUG)
Log.e(Aware.TAG, e.getMessage());
return null;
}
}
use of android.database.sqlite.SQLiteQueryBuilder in project mobile-center-sdk-android by Microsoft.
the class DatabaseManager method getCursor.
/**
* Gets a cursor for all rows in the table, all rows where key matches value if specified.
*
* @param key The optional key for query.
* @param value The optional value for query.
* @param idOnly Return only row identifier if true, return all fields otherwise.
* @return A cursor for all rows that matches the given criteria.
* @throws RuntimeException If an error occurs.
*/
Cursor getCursor(String key, Object value, boolean idOnly) throws RuntimeException {
/* Build a query to get values. */
SQLiteQueryBuilder builder = SQLiteUtils.newSQLiteQueryBuilder();
builder.setTables(mTable);
String[] selectionArgs;
if (key == null) {
selectionArgs = null;
} else if (value == null) {
builder.appendWhere(key + " IS NULL");
selectionArgs = null;
} else {
builder.appendWhere(key + " = ?");
selectionArgs = new String[] { String.valueOf(value.toString()) };
}
/* Query database. */
String[] projectionIn = idOnly ? new String[] { PRIMARY_KEY } : null;
return builder.query(getDatabase(), projectionIn, null, selectionArgs, null, null, PRIMARY_KEY);
}
Aggregations