use of android.database.sqlite.SQLiteException in project DevRing by LJYcoder.
the class NativeTableManager method count.
@Override
public long count() {
int count = 0;
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
String sql = "select count(*) from " + mTableName;
Cursor cursor = null;
try {
cursor = db.rawQuery(sql, null);
if (cursor != null && cursor.moveToFirst()) {
count = cursor.getInt(0);
}
} catch (SQLiteException e) {
RingLog.e(e);
} finally {
if (cursor != null) {
cursor.close();
}
mOpenHelper.close();
}
return count;
}
use of android.database.sqlite.SQLiteException in project DevRing by LJYcoder.
the class NativeTableManager method loadAll.
@Override
public List<M> loadAll() {
List<M> list = null;
String sql = "select * from " + mTableName;
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor cursor = null;
try {
cursor = db.rawQuery(sql, null);
list = cursor != null ? readCursors(cursor) : null;
} catch (SQLiteException e) {
RingLog.e(e);
} finally {
if (cursor != null) {
cursor.close();
}
mOpenHelper.close();
}
return list;
}
use of android.database.sqlite.SQLiteException in project k-9 by k9mail.
the class MigrationTo41 method db41UpdateFolderMetadata.
public static void db41UpdateFolderMetadata(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
Cursor cursor = null;
try {
cursor = db.rawQuery("SELECT id, name FROM folders", null);
while (cursor.moveToNext()) {
try {
int id = cursor.getInt(0);
String name = cursor.getString(1);
update41Metadata(db, migrationsHelper, id, name);
} catch (Exception e) {
Timber.e(e, " error trying to ugpgrade a folder class");
}
}
} catch (SQLiteException e) {
Timber.e(e, "Exception while upgrading database to v41. folder classes may have vanished");
} finally {
Utility.closeQuietly(cursor);
}
}
use of android.database.sqlite.SQLiteException in project k-9 by k9mail.
the class MigrationTo50 method foldersAddNotifyClassColumn.
public static void foldersAddNotifyClassColumn(SQLiteDatabase db, MigrationsHelper migrationsHelper) {
try {
db.execSQL("ALTER TABLE folders ADD notify_class TEXT default '" + Folder.FolderClass.INHERITED.name() + "'");
} catch (SQLiteException e) {
if (!e.getMessage().startsWith("duplicate column name:")) {
throw e;
}
}
ContentValues cv = new ContentValues();
cv.put("notify_class", Folder.FolderClass.FIRST_CLASS.name());
Account account = migrationsHelper.getAccount();
db.update("folders", cv, "name = ?", new String[] { account.getInboxFolderName() });
}
use of android.database.sqlite.SQLiteException in project android-sqlite-asset-helper by jgilfelt.
the class SQLiteAssetHelper method returnDatabase.
private SQLiteDatabase returnDatabase() {
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase(mDatabasePath + "/" + mName, mFactory, SQLiteDatabase.OPEN_READWRITE);
Log.i(TAG, "successfully opened database " + mName);
return db;
} catch (SQLiteException e) {
Log.w(TAG, "could not open database " + mName + " - " + e.getMessage());
return null;
}
}
Aggregations