Search in sources :

Example 1 with SQLiteCantOpenDatabaseException

use of android.database.sqlite.SQLiteCantOpenDatabaseException in project Conversations by siacs.

the class DatabaseBackend method hasEnabledAccounts.

public boolean hasEnabledAccounts() {
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery("select count(" + Account.UUID + ")  from " + Account.TABLENAME + " where not options & (1 <<1)", null);
    try {
        cursor.moveToFirst();
        int count = cursor.getInt(0);
        return (count > 0);
    } catch (SQLiteCantOpenDatabaseException e) {
        // better safe than sorry
        return true;
    } catch (RuntimeException e) {
        // better safe than sorry
        return true;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) SQLiteCantOpenDatabaseException(android.database.sqlite.SQLiteCantOpenDatabaseException) Cursor(android.database.Cursor)

Aggregations

Cursor (android.database.Cursor)1 SQLiteCantOpenDatabaseException (android.database.sqlite.SQLiteCantOpenDatabaseException)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1