android.database.sqlite.SQLiteReadOnlyDatabaseException Java Examples
The following examples show how to use
android.database.sqlite.SQLiteReadOnlyDatabaseException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IconCache.java From Trebuchet with GNU General Public License v3.0 | 5 votes |
/** * Updates {@param values} to contain versoning information and adds it to the DB. * @param values {@link ContentValues} containing icon & title */ private void addIconToDB(ContentValues values, ComponentName key, PackageInfo info, long userSerial) { values.put(IconDB.COLUMN_COMPONENT, key.flattenToString()); values.put(IconDB.COLUMN_USER, userSerial); values.put(IconDB.COLUMN_LAST_UPDATED, info.lastUpdateTime); values.put(IconDB.COLUMN_VERSION, info.versionCode); try { mIconDb.getWritableDatabase().insertWithOnConflict(IconDB.TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); } catch (SQLiteReadOnlyDatabaseException e) { Log.e(TAG, "Can't add icon to read only db", e); } }
Example #2
Source File: WidgetPreviewLoader.java From LB-Launcher with Apache License 2.0 | 5 votes |
public WidgetPreviewLoader(Context context) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); mContext = context; mAppIconSize = grid.iconSizePx; mIconCache = app.getIconCache(); mManager = AppWidgetManagerCompat.getInstance(context); mDb = app.getWidgetPreviewCacheDb(); SharedPreferences sp = context.getSharedPreferences( LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); final String lastVersionName = sp.getString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, null); final String versionName = android.os.Build.VERSION.INCREMENTAL; final boolean isLollipopOrGreater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; if (!versionName.equals(lastVersionName)) { try { // clear all the previews whenever the system version changes, to ensure that // previews are up-to-date for any apps that might have been updated with the system clearDb(); } catch (SQLiteReadOnlyDatabaseException e) { if (isLollipopOrGreater) { // Workaround for Bug. 18554839, if we fail to clear the db due to the read-only // issue, then ignore this error and leave the old previews } else { throw e; } } finally { SharedPreferences.Editor editor = sp.edit(); editor.putString(ANDROID_INCREMENTAL_VERSION_NAME_KEY, versionName); editor.commit(); } } }
Example #3
Source File: FeatureChanges.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public static void delete(String tableName) { try { MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance(); SQLiteDatabase db = map.getDatabase(true); String tableDrop = "DROP TABLE IF EXISTS " + tableName; db.execSQL(tableDrop); } catch (SQLiteFullException | SQLiteReadOnlyDatabaseException e) { e.printStackTrace(); } }