Tabnine Logo
SupportSQLiteDatabase.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
androidx.sqlite.db.SupportSQLiteDatabase

Best Java code snippets using androidx.sqlite.db.SupportSQLiteDatabase.close (Showing top 11 results out of 315)

origin: ankidroid/Anki-Android

/**
 * Closes a previously opened database connection.
 */
public void close() {
  try {
    mDatabase.close();
    Timber.d("Database %s closed = %s", mDatabase.getPath(), !mDatabase.isOpen());
  } catch (Exception e) {
    // The pre-framework requery API ate this exception, but the framework API exposes it.
    // We may want to propagate it in the future, but for now maintain the old API and log.
    Timber.e(e, "Failed to close database %s", this.getDatabase().getPath());
  }
}
origin: oliexdev/openScale

db.close();
origin: oliexdev/openScale

db.close();
origin: commonsguy/cwac-saferoom

@Test(expected = net.sqlcipher.database.SQLiteException.class)
public void defaultBehavior() throws IOException {
 assertTrue(getDbFile().exists());
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getReadableDatabase();
 db.close();
}
origin: commonsguy/cwac-saferoom

private void dekey(Callable<?> decrypter) throws Exception {
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getWritableDatabase();
 assertOriginalContent(db);
 db.close();
 final Context ctxt=InstrumentationRegistry.getTargetContext();
 decrypter.call();
 SQLiteDatabase plainDb=
  SQLiteDatabase.openDatabase(ctxt.getDatabasePath(DB_NAME).getAbsolutePath(),
   null, SQLiteDatabase.OPEN_READWRITE);
 assertOriginalContent(plainDb);
 plainDb.close();
}
origin: oliexdev/openScale

db.close();
origin: commonsguy/cwac-saferoom

private void enkey(Callable<?> encrypter) throws Exception {
 final Context ctxt=InstrumentationRegistry.getTargetContext();
 assertEquals(SQLCipherUtils.State.DOES_NOT_EXIST, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));
 SQLiteDatabase plainDb=
  SQLiteDatabase.openOrCreateDatabase(ctxt.getDatabasePath(DB_NAME).getAbsolutePath(),
   null);
 plainDb.execSQL("CREATE TABLE foo (bar, goo);");
 plainDb.execSQL("INSERT INTO foo (bar, goo) VALUES (?, ?)",
  new Object[] {1, "two"});
 assertOriginalContent(plainDb);
 plainDb.close();
 assertEquals(SQLCipherUtils.State.UNENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));
 encrypter.call();
 assertEquals(SQLCipherUtils.State.ENCRYPTED, SQLCipherUtils.getDatabaseState(ctxt, DB_NAME));
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getReadableDatabase();
 assertOriginalContent(db);
 db.close();
}
origin: commonsguy/cwac-saferoom

@Test
public void wal() throws IOException {
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getWritableDatabase();
 assertFalse(db.isWriteAheadLoggingEnabled());
 assertTrue(db.enableWriteAheadLogging());
 assertTrue(db.isWriteAheadLoggingEnabled());
 db.close();
 factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 db=helper.getWritableDatabase();
 assertTrue(db.isWriteAheadLoggingEnabled());
 db.disableWriteAheadLogging();
 assertFalse(db.isWriteAheadLoggingEnabled());
 db.close();
}
origin: commonsguy/cwac-saferoom

@Test
public void migrate() throws IOException {
 assertTrue(getDbFile().exists());
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
   SafeHelperFactory.POST_KEY_SQL_MIGRATE);
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getReadableDatabase();
 assertOriginalContent(db);
 db.close();
 // with migrate, the change should be permanent
 factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 db=helper.getReadableDatabase();
 assertOriginalContent(db);
 db.close();
}
origin: commonsguy/cwac-saferoom

@Test
public void v3() throws IOException {
 assertTrue(getDbFile().exists());
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE),
   SafeHelperFactory.POST_KEY_SQL_V3);
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getReadableDatabase();
 assertOriginalContent(db);
 db.close();
 // with v3, the change should be temporary
 factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
  new Callback(1));
 boolean didWeGoBoom = false;
 try {
  db = helper.getReadableDatabase();
 }
 catch (net.sqlcipher.database.SQLiteException ex) {
  didWeGoBoom = true;
 }
 assertTrue(didWeGoBoom);
}
origin: commonsguy/cwac-saferoom

@Test
public void rekey() throws IOException {
 SafeHelperFactory factory=
  SafeHelperFactory.fromUser(new SpannableStringBuilder("sekrit"));
 SupportSQLiteOpenHelper helper=
  factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
   new Callback(1));
 SupportSQLiteDatabase db=helper.getWritableDatabase();
 assertOriginalContent(db);
 SafeHelperFactory.rekey(db, new SpannableStringBuilder(PASSPHRASE));
 assertOriginalContent(db);
 db.execSQL("UPDATE foo SET bar=?, goo=?", new Object[] {3, "four"});
 assertUpdatedContent(db);
 db.close();
 factory=SafeHelperFactory.fromUser(new SpannableStringBuilder(PASSPHRASE));
 helper=factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME,
  new Callback(1));
 db=helper.getWritableDatabase();
 assertUpdatedContent(db);
}
androidx.sqlite.dbSupportSQLiteDatabaseclose

Popular methods of SupportSQLiteDatabase

  • execSQL
  • query
  • beginTransaction
  • disableWriteAheadLogging
  • endTransaction
  • insert
  • setTransactionSuccessful
  • enableWriteAheadLogging
  • getPath
  • inTransaction
  • isOpen
  • isWriteAheadLoggingEnabled
  • isOpen,
  • isWriteAheadLoggingEnabled,
  • setForeignKeyConstraintsEnabled,
  • update

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now