use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.
the class ActivityDataSource method insertMultiple.
private synchronized int insertMultiple(ContentValues[] allValues) {
int rowsAdded = 0;
long rowId;
ContentValues values;
if (database == null || !database.isOpen()) {
open();
}
try {
database.beginTransaction();
for (ContentValues initialValues : allValues) {
values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
try {
rowId = database.insert(ActivitySQLiteHelper.TABLE_ACTIVITY, null, values);
} catch (IllegalStateException e) {
return rowsAdded;
}
if (rowId > 0)
rowsAdded++;
}
database.setTransactionSuccessful();
} catch (NullPointerException e) {
e.printStackTrace();
return rowsAdded;
} catch (SQLiteDatabaseLockedException e) {
e.printStackTrace();
return rowsAdded;
} catch (IllegalStateException e) {
// caught setting up the transaction I guess, shouldn't ever happen now.
e.printStackTrace();
return rowsAdded;
} finally {
try {
database.endTransaction();
} catch (Exception e) {
// shouldn't happen unless it gets caught above from an illegal state
}
}
return rowsAdded;
}
use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.
the class ListDataSource method insertMultiple.
private synchronized int insertMultiple(ContentValues[] allValues) {
int rowsAdded = 0;
long rowId;
ContentValues values;
if (database == null || !database.isOpen()) {
open();
}
try {
database.beginTransaction();
for (ContentValues initialValues : allValues) {
values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
try {
rowId = database.insert(ListSQLiteHelper.TABLE_HOME, null, values);
} catch (IllegalStateException e) {
return rowsAdded;
}
if (rowId > 0)
rowsAdded++;
}
database.setTransactionSuccessful();
} catch (NullPointerException e) {
e.printStackTrace();
return rowsAdded;
} catch (SQLiteDatabaseLockedException e) {
e.printStackTrace();
return rowsAdded;
} catch (IllegalStateException e) {
// caught setting up the transaction I guess, shouldn't ever happen now.
e.printStackTrace();
return rowsAdded;
} finally {
try {
database.endTransaction();
} catch (Exception e) {
// shouldn't happen unless it gets caught above from an illegal state
}
}
return rowsAdded;
}
use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.
the class MentionsDataSource method insertMultiple.
private synchronized int insertMultiple(ContentValues[] allValues) {
int rowsAdded = 0;
long rowId;
ContentValues values;
if (database == null || !database.isOpen()) {
open();
}
try {
database.beginTransaction();
for (ContentValues initialValues : allValues) {
values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
try {
rowId = database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
} catch (IllegalStateException e) {
return rowsAdded;
}
if (rowId > 0)
rowsAdded++;
}
database.setTransactionSuccessful();
} catch (NullPointerException e) {
e.printStackTrace();
return rowsAdded;
} catch (SQLiteDatabaseLockedException e) {
e.printStackTrace();
return rowsAdded;
} catch (IllegalStateException e) {
// caught setting up the transaction I guess, shouldn't ever happen now.
e.printStackTrace();
return rowsAdded;
} finally {
try {
database.endTransaction();
} catch (Exception e) {
// shouldn't happen unless it gets caught above from an illegal state
}
}
return rowsAdded;
}
use of android.database.sqlite.SQLiteDatabaseLockedException in project Talon-for-Twitter by klinker24.
the class HomeContentProvider method insertMultiple.
private int insertMultiple(ContentValues[] allValues) {
int rowsAdded = 0;
long rowId;
ContentValues values;
SQLiteDatabase db = HomeDataSource.getInstance(getContext()).getDatabase();
try {
db.beginTransaction();
for (ContentValues initialValues : allValues) {
values = initialValues == null ? new ContentValues() : new ContentValues(initialValues);
try {
rowId = db.insert(HomeSQLiteHelper.TABLE_HOME, null, values);
} catch (IllegalStateException e) {
return rowsAdded;
//db = HomeDataSource.getInstance(context).getDatabase();
//rowId = 0;
}
if (rowId > 0)
rowsAdded++;
}
db.setTransactionSuccessful();
} catch (NullPointerException e) {
e.printStackTrace();
return rowsAdded;
} catch (SQLiteDatabaseLockedException e) {
e.printStackTrace();
return rowsAdded;
} catch (IllegalStateException e) {
// caught setting up the transaction I guess, shouldn't ever happen now.
e.printStackTrace();
return rowsAdded;
} finally {
try {
db.endTransaction();
} catch (Exception e) {
// shouldn't happen unless it gets caught above from an illegal state
}
}
return rowsAdded;
}
Aggregations