private void recreateLocked() { synchronized (databaseInstanceLock) { closeAndDeleteLocked(); getDatabase(); } }
/** * Clear all data in the database. This method acquires the exclusive lock before closing the db -- it will block * if other threads are in transactions. This method will throw an exception if called from within a transaction. * <p> * It is not safe to call this method from within any of the database open or migration hooks (e.g. * {@link #onUpgrade(ISQLiteDatabase, int, int)}, {@link #onOpen(ISQLiteDatabase)}, * {@link #onMigrationFailed(MigrationFailedException)}), etc. * <p> * WARNING: Any open database resources (e.g. cursors) will be invalid after calling this method. Do not call this * method if any open cursors may be in use. The existing database file will be deleted and all data will be lost. */ public final void clear() { acquireExclusiveLock(); try { closeAndDeleteLocked(); } finally { releaseExclusiveLock(); } }
private void recreateLocked() { synchronized (databaseInstanceLock) { closeAndDeleteLocked(); getDatabase(); } }
/** * Clear all data in the database. This method acquires the exclusive lock before closing the db -- it will block * if other threads are in transactions. This method will throw an exception if called from within a transaction. * <p> * It is not safe to call this method from within any of the database open or migration hooks (e.g. * {@link #onUpgrade(ISQLiteDatabase, int, int)}, {@link #onOpen(ISQLiteDatabase)}, * {@link #onMigrationFailed(MigrationFailedException)}), etc. * <p> * WARNING: Any open database resources (e.g. cursors) will be invalid after calling this method. Do not call this * method if any open cursors may be in use. The existing database file will be deleted and all data will be lost. */ public final void clear() { acquireExclusiveLock(); try { closeAndDeleteLocked(); } finally { releaseExclusiveLock(); } }