catch can't open database exception

This commit is contained in:
iNPUTmice 2014-10-14 18:26:45 +02:00
parent e98460771b
commit 031b739af8
1 changed files with 9 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Roster; import eu.siacs.conversations.entities.Roster;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteCantOpenDatabaseException;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
@ -231,10 +232,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("select count(" + Account.UUID + ") from " Cursor cursor = db.rawQuery("select count(" + Account.UUID + ") from "
+ Account.TABLENAME + " where not options & (1 <<1)", null); + Account.TABLENAME + " where not options & (1 <<1)", null);
try {
cursor.moveToFirst(); cursor.moveToFirst();
int count = cursor.getInt(0); int count = cursor.getInt(0);
cursor.close(); cursor.close();
return (count > 0); return (count > 0);
} catch (SQLiteCantOpenDatabaseException e) {
return true; //better safe than sorry
}
} }
@Override @Override