LauncherProviderpublic class LauncherProvider extends android.content.ContentProvider
Fields Summary |
---|
private static final String | LOG_TAG | private static final boolean | LOGD | private static final String | DATABASE_NAME | private static final int | DATABASE_VERSION | static final String | AUTHORITY | static final String | EXTRA_BIND_SOURCES | static final String | EXTRA_BIND_TARGETS | static final String | TABLE_FAVORITES | static final String | PARAMETER_NOTIFY | static final android.net.Uri | CONTENT_APPWIDGET_RESET_URI{@link Uri} triggered at any registered {@link ContentObserver} when
{@link AppWidgetHost#deleteHost()} is called during database creation.
Use this to recall {@link AppWidgetHost#startListening()} if needed. | private android.database.sqlite.SQLiteOpenHelper | mOpenHelper |
Methods Summary |
---|
static java.lang.String | buildOrWhereString(java.lang.String column, int[] values)Build a query string that will match any row where the column matches
anything in the values list.
StringBuilder selectWhere = new StringBuilder();
for (int i = values.length - 1; i >= 0; i--) {
selectWhere.append(column).append("=").append(values[i]);
if (i > 0) {
selectWhere.append(" OR ");
}
}
return selectWhere.toString();
| public int | bulkInsert(android.net.Uri uri, android.content.ContentValues[] values)
SqlArguments args = new SqlArguments(uri);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
try {
int numValues = values.length;
for (int i = 0; i < numValues; i++) {
if (db.insert(args.table, null, values[i]) < 0) return 0;
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
sendNotify(uri);
return values.length;
| public int | delete(android.net.Uri uri, java.lang.String selection, java.lang.String[] selectionArgs)
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
int count = db.delete(args.table, args.where, args.args);
if (count > 0) sendNotify(uri);
return count;
| public java.lang.String | getType(android.net.Uri uri)
SqlArguments args = new SqlArguments(uri, null, null);
if (TextUtils.isEmpty(args.where)) {
return "vnd.android.cursor.dir/" + args.table;
} else {
return "vnd.android.cursor.item/" + args.table;
}
| public android.net.Uri | insert(android.net.Uri uri, android.content.ContentValues initialValues)
SqlArguments args = new SqlArguments(uri);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
final long rowId = db.insert(args.table, null, initialValues);
if (rowId <= 0) return null;
uri = ContentUris.withAppendedId(uri, rowId);
sendNotify(uri);
return uri;
| public boolean | onCreate()
mOpenHelper = new DatabaseHelper(getContext());
return true;
| public android.database.Cursor | query(android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setTables(args.table);
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor result = qb.query(db, projection, args.where, args.args, null, null, sortOrder);
result.setNotificationUri(getContext().getContentResolver(), uri);
return result;
| private void | sendNotify(android.net.Uri uri)
String notify = uri.getQueryParameter(PARAMETER_NOTIFY);
if (notify == null || "true".equals(notify)) {
getContext().getContentResolver().notifyChange(uri, null);
}
| public int | update(android.net.Uri uri, android.content.ContentValues values, java.lang.String selection, java.lang.String[] selectionArgs)
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
SQLiteDatabase db = mOpenHelper.getWritableDatabase();
int count = db.update(args.table, values, args.where, args.args);
if (count > 0) sendNotify(uri);
return count;
|
|