use of android.database.sqlite.SQLiteQueryBuilder in project bitcoin-wallet by bitcoin-wallet.
the class AddressBookProvider method query.
@Override
public Cursor query(final Uri uri, final String[] projection, final String originalSelection, final String[] originalSelectionArgs, final String sortOrder) {
final SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(DATABASE_TABLE);
final List<String> pathSegments = uri.getPathSegments();
if (pathSegments.size() > 1)
throw new IllegalArgumentException(uri.toString());
String selection = null;
String[] selectionArgs = null;
if (pathSegments.size() == 1) {
final String address = uri.getLastPathSegment();
qb.appendWhere(KEY_ADDRESS + "=");
qb.appendWhereEscapeString(address);
} else if (SELECTION_IN.equals(originalSelection)) {
final String[] addresses = originalSelectionArgs[0].trim().split(",");
qb.appendWhere(KEY_ADDRESS + " IN (");
appendAddresses(qb, addresses);
qb.appendWhere(")");
} else if (SELECTION_NOTIN.equals(originalSelection)) {
final String[] addresses = originalSelectionArgs[0].trim().split(",");
qb.appendWhere(KEY_ADDRESS + " NOT IN (");
appendAddresses(qb, addresses);
qb.appendWhere(")");
} else if (SELECTION_QUERY.equals(originalSelection)) {
final String query = '%' + originalSelectionArgs[0].trim() + '%';
selection = KEY_ADDRESS + " LIKE ? OR " + KEY_LABEL + " LIKE ?";
selectionArgs = new String[] { query, query };
}
final Cursor cursor = qb.query(helper.getReadableDatabase(), projection, selection, selectionArgs, null, null, sortOrder);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
return cursor;
}
use of android.database.sqlite.SQLiteQueryBuilder in project aware-client by denzilferreira.
the class Significant_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_DATA:
qb.setTables(DATABASE_TABLES[0]);
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 Telephony_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 TELEPHONY:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(telephonyMap);
break;
case GSM:
qb.setTables(DATABASE_TABLES[1]);
qb.setProjectionMap(gsmMap);
break;
case NEIGHBOR:
qb.setTables(DATABASE_TABLES[2]);
qb.setProjectionMap(gsmNeighborsMap);
break;
case CDMA:
qb.setTables(DATABASE_TABLES[3]);
qb.setProjectionMap(cdmaMap);
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 Temperature_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 Accelerometer_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 ACCEL_DEV:
qb.setTables(DATABASE_TABLES[0]);
qb.setProjectionMap(accelDeviceMap);
break;
case ACCEL_DATA:
qb.setTables(DATABASE_TABLES[1]);
qb.setProjectionMap(accelDataMap);
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;
}
}
Aggregations