android.database.sqlite.SQLiteDatabaseCorruptException Java Examples
The following examples show how to use
android.database.sqlite.SQLiteDatabaseCorruptException.
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: DatabaseUtils.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static final void readExceptionFromParcel(Parcel reply, String msg, int code) { switch (code) { case 2: throw new IllegalArgumentException(msg); case 3: throw new UnsupportedOperationException(msg); case 4: throw new SQLiteAbortException(msg); case 5: throw new SQLiteConstraintException(msg); case 6: throw new SQLiteDatabaseCorruptException(msg); case 7: throw new SQLiteFullException(msg); case 8: throw new SQLiteDiskIOException(msg); case 9: throw new SQLiteException(msg); case 11: throw new OperationCanceledException(msg); default: reply.readException(code, msg); } }
Example #2
Source File: MyApplication.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
private void initUnhandledExceptionHandler() { defaultHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(@NotNull Thread thread, @NotNull Throwable ex) { Timber.e(ex, "CRASHED"); if (ExceptionUtils.getRootCause(ex) instanceof SQLiteDatabaseCorruptException) { MeasurementsDatabase.deleteDatabase(getApplication()); } // strange but it happens that app is tested on devices with lower SDK - don't send ACRA reports // also ignore errors caused by system failures if (Build.VERSION.SDK_INT >= BuildConfig.MIN_SDK_VERSION && !(ExceptionUtils.getRootCause(ex) instanceof DeadObjectException)) { defaultHandler.uncaughtException(thread, ex); } } }); }
Example #3
Source File: OpenScale.java From openScale with GNU General Public License v3.0 | 6 votes |
public void reopenDatabase(boolean truncate) throws SQLiteDatabaseCorruptException { if (appDB != null) { appDB.close(); } appDB = Room.databaseBuilder(context, AppDatabase.class, DATABASE_NAME) .allowMainThreadQueries() .setJournalMode(truncate == true ? RoomDatabase.JournalMode.TRUNCATE : RoomDatabase.JournalMode.AUTOMATIC) // in truncate mode no sql cache files (-shm, -wal) are generated .addCallback(new RoomDatabase.Callback() { @Override public void onOpen(SupportSQLiteDatabase db) { super.onOpen(db); db.setForeignKeyConstraintsEnabled(true); } }) .addMigrations(AppDatabase.MIGRATION_1_2, AppDatabase.MIGRATION_2_3, AppDatabase.MIGRATION_3_4, AppDatabase.MIGRATION_4_5) .build(); measurementDAO = appDB.measurementDAO(); userDAO = appDB.userDAO(); }
Example #4
Source File: OpenScale.java From openScale with GNU General Public License v3.0 | 6 votes |
public void importDatabase(Uri importFile) throws IOException { File exportFile = context.getApplicationContext().getDatabasePath("openScale.db"); File tmpExportFile = context.getApplicationContext().getDatabasePath("openScale_tmp.db"); try { copyFile(Uri.fromFile(exportFile), Uri.fromFile(tmpExportFile)); copyFile(importFile, Uri.fromFile(exportFile)); reopenDatabase(false); if (!getScaleUserList().isEmpty()) { selectScaleUser(getScaleUserList().get(0).getId()); } } catch (SQLiteDatabaseCorruptException e) { copyFile(Uri.fromFile(tmpExportFile), Uri.fromFile(exportFile)); throw new IOException(e.getMessage()); } finally { tmpExportFile.delete(); } }
Example #5
Source File: AnsContentProvider.java From ans-android-sdk with GNU General Public License v3.0 | 5 votes |
@Override public int delete(Uri uri, String selection, String[] selectionArgs) { if (uri == null) { return -2; } if (Process.myUid() != Binder.getCallingUid()) { return -4; } int code = -3; switch (uriMatcher.match(uri)) { case EventTableMetaData.TABLE_FZ_DIR: { try { code = deleteDb(uri, selection, selectionArgs); } catch (SQLiteDatabaseCorruptException sql) { dataCorruptException(); } catch (SQLiteException sqLiteException) { tableException(sqLiteException); } catch (Throwable ignore) { ExceptionUtil.exceptionThrow(ignore); } } break; case EventTableMetaData.TABLE_SP_DIR: { } break; default: break; } if (mContext != null && mContext.getContentResolver() != null) { mContext.getContentResolver().notifyChange(uri, null); } return code; }
Example #6
Source File: DatabaseUtils.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Special function for writing an exception result at the header of * a parcel, to be used when returning an exception from a transaction. * exception will be re-thrown by the function in another process * @param reply Parcel to write to * @param e The Exception to be written. * @see Parcel#writeNoException * @see Parcel#writeException */ public static final void writeExceptionToParcel(Parcel reply, Exception e) { int code = 0; boolean logException = true; if (e instanceof FileNotFoundException) { code = 1; logException = false; } else if (e instanceof IllegalArgumentException) { code = 2; } else if (e instanceof UnsupportedOperationException) { code = 3; } else if (e instanceof SQLiteAbortException) { code = 4; } else if (e instanceof SQLiteConstraintException) { code = 5; } else if (e instanceof SQLiteDatabaseCorruptException) { code = 6; } else if (e instanceof SQLiteFullException) { code = 7; } else if (e instanceof SQLiteDiskIOException) { code = 8; } else if (e instanceof SQLiteException) { code = 9; } else if (e instanceof OperationApplicationException) { code = 10; } else if (e instanceof OperationCanceledException) { code = 11; logException = false; } else { reply.writeException(e); Log.e(TAG, "Writing exception to parcel", e); return; } reply.writeInt(code); reply.writeString(e.getMessage()); if (logException) { Log.e(TAG, "Writing exception to parcel", e); } }
Example #7
Source File: MapBoxOfflineTileProvider.java From ground-android with Apache License 2.0 | 5 votes |
private void calculateZoomConstraints() { if (this.isDatabaseAvailable()) { String[] projection = new String[] { "value" }; String[] minArgs = new String[] { "minzoom" }; String[] maxArgs = new String[] { "maxzoom" }; Cursor c; try { c = this.mDatabase.query("metadata", projection, "name = ?", minArgs, null, null, null); c.moveToFirst(); if (!c.isAfterLast()) { this.mMinimumZoom = c.getInt(0); } c.close(); c = this.mDatabase.query("metadata", projection, "name = ?", maxArgs, null, null, null); c.moveToFirst(); if (!c.isAfterLast()) { this.mMaximumZoom = c.getInt(0); } c.close(); } catch (SQLiteDatabaseCorruptException e) { Log.e("MAPBOX: ", "SQLite error: ", e); } } }
Example #8
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Execute this SQL statement, if it is not a SELECT / INSERT / DELETE / UPDATE, for example * CREATE / DROP table, view, trigger, index etc. * * @throws SQLException If the SQL string is invalid for some reason */ @Override public void execute() { acquireReference(); try { getSession().execute(getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }
Example #9
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Execute this SQL statement, if the the number of rows affected by execution of this SQL * statement is of any importance to the caller - for example, UPDATE / DELETE SQL statements. * * @return the number of rows affected by this SQL statement execution. * @throws SQLException If the SQL string is invalid for some reason */ @Override public int executeUpdateDelete() { acquireReference(); try { return getSession().executeForChangedRowCount( getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }
Example #10
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Execute this SQL statement and return the ID of the row inserted due to this call. * The SQL statement should be an INSERT for this to be a useful call. * * @return the row ID of the last row inserted, if this insert is successful. -1 otherwise. * * @throws SQLException If the SQL string is invalid for some reason */ @Override public long executeInsert() { acquireReference(); try { return getSession().executeForLastInsertedRowId( getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }
Example #11
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Execute a statement that returns a 1 by 1 table with a numeric value. * For example, SELECT COUNT(*) FROM table; * * @return The result of the query. * * @throws SQLiteDoneException if the query returns zero rows */ @Override public long simpleQueryForLong() { acquireReference(); try { return getSession().executeForLong( getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }
Example #12
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Execute a statement that returns a 1 by 1 table with a text value. * For example, SELECT COUNT(*) FROM table; * * @return The result of the query. * * @throws SQLiteDoneException if the query returns zero rows */ @Override public String simpleQueryForString() { acquireReference(); try { return getSession().executeForString( getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }
Example #13
Source File: SQLiteStatement.java From sqlite-android with Apache License 2.0 | 5 votes |
/** * Executes a statement that returns a 1 by 1 table with a blob value. * * @return A read-only file descriptor for a copy of the blob value, or {@code null} * if the value is null or could not be read for some reason. * * @throws SQLiteDoneException if the query returns zero rows */ public ParcelFileDescriptor simpleQueryForBlobFileDescriptor() { acquireReference(); try { return getSession().executeForBlobFileDescriptor( getSql(), getBindArgs(), getConnectionFlags(), null); } catch (SQLiteDatabaseCorruptException ex) { onCorruption(); throw ex; } finally { releaseReference(); } }