Codota Logo
SQLiteDatabase.isOpen
Code IndexAdd Codota to your IDE (free)

How to use
isOpen
method
in
android.database.sqlite.SQLiteDatabase

Best Java code snippets using android.database.sqlite.SQLiteDatabase.isOpen (Showing top 20 results out of 1,125)

  • Common ways to obtain SQLiteDatabase
private void myMethod () {
SQLiteDatabase s =
  • Codota IconSQLiteOpenHelper dbHelper;dbHelper.getWritableDatabase()
  • Codota IconWeatherDbHelper dbHelper;dbHelper.getWritableDatabase()
  • Codota IconSQLiteOpenHelper dbHelper;dbHelper.getReadableDatabase()
  • Smart code suggestions by Codota
}
origin: greenrobot/greenDAO

@Override
public boolean isOpen() {
  return delegate.isOpen();
}
origin: yanzhenjie/NoHttp

/**
 * Close the database when reading data.
 *
 * @param database {@link SQLiteDatabase}.
 */
protected final void closeDateBase(SQLiteDatabase database) {
  if (database != null && database.isOpen())
    database.close();
}
origin: stackoverflow.com

 File dbfile = new File("/sdcard/mydb.sqlite" ); 
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
System.out.println("Its open? "  + db.isOpen());
origin: jeasonlzy/okhttp-OkGo

protected final void closeDatabase(SQLiteDatabase database, Cursor cursor) {
  if (cursor != null && !cursor.isClosed()) cursor.close();
  if (database != null && database.isOpen()) database.close();
}
origin: jeasonlzy/okhttp-OkGo

  public static boolean isFieldExists(SQLiteDatabase db, String tableName, String fieldName) {
    if (tableName == null || db == null || fieldName == null || !db.isOpen()) return false;

    Cursor cursor = null;
    try {
      cursor = db.rawQuery("SELECT * FROM " + tableName + " LIMIT 0", null);
      return cursor != null && cursor.getColumnIndex(fieldName) != -1;
    } catch (Exception e) {
      OkLogger.printStackTrace(e);
      return false;
    } finally {
      if (cursor != null) {
        cursor.close();
      }
    }
  }
}
origin: ankidroid/Anki-Android

/** Open the meta-db but only if it currently closed. */
private static void openDBIfClosed(Context context) {
  if (mMetaDb == null || !mMetaDb.isOpen()) {
    openDB(context);
  }
}
origin: square/assertj-android

public SqliteDatabaseAssert isOpen() {
 isNotNull();
 assertThat(actual.isOpen()) //
   .overridingErrorMessage("Expected DB to be open but was not.") //
   .isTrue();
 return this;
}
origin: robolectric/robolectric

@Test
public void testIsOpen() throws Exception {
  assertThat(database.isOpen()).isTrue();
  database.close();
  assertThat(database.isOpen()).isFalse();
}
origin: robolectric/robolectric

@Test
public void shouldOpenExistingDatabaseFromFileSystemIfFileExists() throws Exception {
  database.close();
  SQLiteDatabase db = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, OPEN_READWRITE);
  Cursor c = db.rawQuery("select * from rawtable", null);
  assertThat(c).isNotNull();
  assertThat(c.getCount()).isEqualTo(2);
  assertThat(db.isOpen()).isTrue();
  db.close();
  assertThat(db.isOpen()).isFalse();
  SQLiteDatabase reopened = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, OPEN_READWRITE);
  assertThat(reopened).isNotSameAs(db);
  assertThat(reopened.isOpen()).isTrue();
}
origin: robolectric/robolectric

@Test
public void testClose() throws Exception {
 SQLiteDatabase database = helper.getWritableDatabase();
 assertThat(database.isOpen()).isTrue();
 helper.close();
 assertThat(database.isOpen()).isFalse();
}
origin: robolectric/robolectric

private static void assertDatabaseOpened(SQLiteDatabase database, TestOpenHelper helper) {
 assertThat(database).isNotNull();
 assertThat(database.isOpen()).isTrue();
 assertThat(helper.onOpenCalled).isTrue();
 assertThat(helper.onUpgradeCalled).isFalse();
}
origin: robolectric/robolectric

@Test
public void testCloseMultipleDbs() throws Exception {
 TestOpenHelper helper2 =
   new TestOpenHelper(ApplicationProvider.getApplicationContext(), "path2", null, 1);
 SQLiteDatabase database1 = helper.getWritableDatabase();
 SQLiteDatabase database2 = helper2.getWritableDatabase();
 assertThat(database1.isOpen()).isTrue();
 assertThat(database2.isOpen()).isTrue();
 helper.close();
 assertThat(database1.isOpen()).isFalse();
 assertThat(database2.isOpen()).isTrue();
 helper2.close();
 assertThat(database2.isOpen()).isFalse();
}
origin: evernote/android-job

  @Test
  public void verifyDeleteWhileOpening() {
    Context context = RuntimeEnvironment.application;

    String filePath = getClass().getResource("/databases/corrupted.db").getPath();
    final long originalLength = new File(filePath).length();

    assertThat(new File(filePath).exists()).isTrue();

    JobStorage jobStorage = new JobStorage(context, filePath);
    SQLiteDatabase database = jobStorage.getDatabase();

    assertThat(database).isNotNull();
    assertThat(database.isOpen()).isTrue();
    assertThat(originalLength).isNotEqualTo(new File(filePath).length());

    File databaseFile = new File(database.getPath());
    assertThat(databaseFile.exists()).isTrue();
    assertThat(databaseFile.isFile()).isTrue();
  }
}
origin: robolectric/robolectric

@Test
public void shouldUseInMemoryDatabaseWhenCallingCreate() throws Exception {
  SQLiteDatabase db = SQLiteDatabase.create(null);
  assertThat(db.isOpen()).isTrue();
  assertThat(db.getPath()).isEqualTo(":memory:");
}
origin: evernote/android-job

@Test
public void verifyDeleteAfterCorruptionWhileOpen() {
  Context context = RuntimeEnvironment.application;
  JobStorage jobStorage = new JobStorage(context);
  SQLiteDatabase database = jobStorage.getDatabase();
  assertThat(database).isNotNull();
  assertThat(database.isOpen()).isTrue();
  File file = new File(database.getPath());
  assertThat(file.exists()).isTrue();
  assertThat(file.isFile()).isTrue();
  new JobStorageDatabaseErrorHandler().onCorruption(database);
  assertThat(file.exists()).isFalse();
}
origin: grandcentrix/tray

public void testShutdown() throws Exception {
  final TrayContentProvider provider = startupProvider();
  final SQLiteDatabase writableDatabase = provider.mUserDbHelper.getWritableDatabase();
  assertTrue(writableDatabase.isOpen());
  provider.shutdown();
  assertFalse(writableDatabase.isOpen());
}
origin: evernote/android-job

@Test
public void verifyDeleteAfterCorruptionWhileClosed() {
  Context context = RuntimeEnvironment.application;
  JobStorage jobStorage = new JobStorage(context);
  SQLiteDatabase database = jobStorage.getDatabase();
  assertThat(database).isNotNull();
  assertThat(database.isOpen()).isTrue();
  File file = new File(database.getPath());
  assertThat(file.exists()).isTrue();
  assertThat(file.isFile()).isTrue();
  database.close();
  new JobStorageDatabaseErrorHandler().onCorruption(database);
  assertThat(file.exists()).isFalse();
}
origin: evernote/android-job

@Test
public void verifyDeleteWithApi14() {
  Context context = RuntimeEnvironment.application;
  JobStorage jobStorage = new JobStorage(context);
  SQLiteDatabase database = jobStorage.getDatabase();
  assertThat(database).isNotNull();
  assertThat(database.isOpen()).isTrue();
  File file = new File(database.getPath());
  assertThat(file.exists()).isTrue();
  assertThat(file.isFile()).isTrue();
  new JobStorageDatabaseErrorHandler().deleteApi14(context, file);
  assertThat(file.exists()).isFalse();
}
origin: robolectric/robolectric

@Test
public void testCloseThenOpen() throws Exception {
 final String TABLE_NAME1 = "fart";
 SQLiteDatabase db1 = helper.getWritableDatabase();
 setupTable(db1, TABLE_NAME1);
 insertData(db1, TABLE_NAME1, new int[]{1, 2});
 verifyData(db1, TABLE_NAME1, 2);
 db1.close();
 db1 = helper.getWritableDatabase();
 assertThat(db1.isOpen()).isTrue();
}
origin: grandcentrix/tray

public TrayContentProvider startupProvider() {
  final TrayContentProvider provider = new TrayContentProvider();
  provider.attachInfo(getProviderMockContext(), getMockProviderInfo());
  assertTrue(provider.onCreate());
  assertTrue(provider.mUserDbHelper.getWritableDatabase().isOpen());
  return provider;
}
android.database.sqliteSQLiteDatabaseisOpen

Popular methods of SQLiteDatabase

  • execSQL
  • insert
  • delete
  • query
  • rawQuery
  • close
  • update
  • endTransaction
  • setTransactionSuccessful
  • beginTransaction
  • compileStatement
  • getVersion
  • compileStatement,
  • getVersion,
  • insertWithOnConflict,
  • openDatabase,
  • insertOrThrow,
  • replace,
  • getPath,
  • openOrCreateDatabase,
  • setVersion

Popular in Java

  • Making http post requests using okhttp
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now