| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
package com.google.android.mms.util; |
| 19 |
|
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.content.ContentResolver; |
| 22 |
import android.content.ContentValues; |
| 23 |
import android.content.Context; |
| 24 |
import android.database.Cursor; |
| 25 |
import android.database.sqlite.SQLiteException; |
| 26 |
import android.net.Uri; |
| 27 |
import android.util.Log; |
| 28 |
|
| 29 |
public final class SqliteWrapper { |
| 30 |
private static final String TAG = "SqliteWrapper"; |
| 31 |
|
| 32 |
private SqliteWrapper() { |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
@UnsupportedAppUsage |
| 37 |
public static Cursor query(Context context, ContentResolver resolver, Uri uri, |
| 38 |
String[] projection, String selection, String[] selectionArgs, String sortOrder) { |
| 39 |
try { |
| 40 |
return resolver.query(uri, projection, selection, selectionArgs, sortOrder); |
| 41 |
} catch (SQLiteException e) { |
| 42 |
Log.e(TAG, "Catch a SQLiteException when query: ", e); |
| 43 |
return null; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
@UnsupportedAppUsage |
| 48 |
public static int update(Context context, ContentResolver resolver, Uri uri, |
| 49 |
ContentValues values, String where, String[] selectionArgs) { |
| 50 |
try { |
| 51 |
return resolver.update(uri, values, where, selectionArgs); |
| 52 |
} catch (SQLiteException e) { |
| 53 |
Log.e(TAG, "Catch a SQLiteException when update: ", e); |
| 54 |
return -1; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
@UnsupportedAppUsage |
| 59 |
public static int delete(Context context, ContentResolver resolver, Uri uri, |
| 60 |
String where, String[] selectionArgs) { |
| 61 |
try { |
| 62 |
return resolver.delete(uri, where, selectionArgs); |
| 63 |
} catch (SQLiteException e) { |
| 64 |
Log.e(TAG, "Catch a SQLiteException when delete: ", e); |
| 65 |
return -1; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
@UnsupportedAppUsage |
| 70 |
public static Uri insert(Context context, ContentResolver resolver, |
| 71 |
Uri uri, ContentValues values) { |
| 72 |
try { |
| 73 |
return resolver.insert(uri, values); |
| 74 |
} catch (SQLiteException e) { |
| 75 |
Log.e(TAG, "Catch a SQLiteException when insert: ", e); |
| 76 |
return null; |
| 77 |
} |
| 78 |
} |
| 79 |
} |