SqliteWrapperpublic final class SqliteWrapper extends Object
Fields Summary |
---|
private static final String | TAG | private static final String | SQLITE_EXCEPTION_DETAIL_MESSAGE |
Constructors Summary |
---|
private SqliteWrapper()
// Forbidden being instantiated.
|
Methods Summary |
---|
public static void | checkSQLiteException(android.content.Context context, android.database.sqlite.SQLiteException e)
if (isLowMemory(e)) {
Toast.makeText(context, com.android.internal.R.string.low_memory,
Toast.LENGTH_SHORT).show();
} else {
throw e;
}
| public static int | delete(android.content.Context context, android.content.ContentResolver resolver, android.net.Uri uri, java.lang.String where, java.lang.String[] selectionArgs)
try {
return resolver.delete(uri, where, selectionArgs);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when delete: ", e);
checkSQLiteException(context, e);
return -1;
}
| public static android.net.Uri | insert(android.content.Context context, android.content.ContentResolver resolver, android.net.Uri uri, android.content.ContentValues values)
try {
return resolver.insert(uri, values);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when insert: ", e);
checkSQLiteException(context, e);
return null;
}
| private static boolean | isLowMemory(android.content.Context context)
if (null == context) {
return false;
}
ActivityManager am = (ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
am.getMemoryInfo(outInfo);
return outInfo.lowMemory;
| private static boolean | isLowMemory(android.database.sqlite.SQLiteException e)
return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
| public static android.database.Cursor | query(android.content.Context context, android.content.ContentResolver resolver, android.net.Uri uri, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)
try {
return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when query: ", e);
checkSQLiteException(context, e);
return null;
}
| public static boolean | requery(android.content.Context context, android.database.Cursor cursor)
try {
return cursor.requery();
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when requery: ", e);
checkSQLiteException(context, e);
return false;
}
| public static int | update(android.content.Context context, android.content.ContentResolver resolver, android.net.Uri uri, android.content.ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)
try {
return resolver.update(uri, values, where, selectionArgs);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when update: ", e);
checkSQLiteException(context, e);
return -1;
}
|
|