use of android.database.sqlite.SQLiteFullException in project MiMangaNu by raulhaag.
the class Database method markChapter.
static void markChapter(Context context, int capId, boolean read) {
ContentValues cv = new ContentValues();
cv.put(COL_CAP_STATE, read ? Chapter.READ : Chapter.UNREAD);
try {
SQLiteDatabase database = getDatabase(context);
if (!database.isReadOnly()) {
database.update(TABLE_CHAPTERS, cv, COL_CAP_ID + " = " + capId, null);
} else {
Log.e("Database", "(markChapter) " + context.getResources().getString(R.string.error_database_is_read_only));
Util.getInstance().toast(context, context.getResources().getString(R.string.error_database_is_read_only));
}
} catch (SQLiteFullException sqlfe) {
Log.e("Database", "SQLiteFullException", sqlfe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (SQLiteDiskIOException sqldioe) {
Log.e("Database", "SQLiteDiskIOException", sqldioe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (Exception e) {
Log.e("Database", "Exception", e);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
}
}
use of android.database.sqlite.SQLiteFullException in project MiMangaNu by raulhaag.
the class Database method updateReadOrder.
public static void updateReadOrder(Context context, int ordinal, int mid) {
ContentValues cv = new ContentValues();
cv.put(COL_READ_ORDER, ordinal);
try {
SQLiteDatabase database = getDatabase(context);
if (!database.isReadOnly()) {
database.update(TABLE_MANGA, cv, COL_ID + "=" + mid, null);
} else {
Log.e("Database", "(updateReadOrder) " + context.getResources().getString(R.string.error_database_is_read_only));
Util.getInstance().toast(context, context.getResources().getString(R.string.error_database_is_read_only));
}
} catch (SQLiteFullException sqlfe) {
Log.e("Database", "SQLiteFullException", sqlfe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (SQLiteDiskIOException sqldioe) {
Log.e("Database", "SQLiteDiskIOException", sqldioe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (Exception e) {
Log.e("Database", "Exception", e);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
}
}
use of android.database.sqlite.SQLiteFullException in project Zom-Android by zom.
the class ImPluginHelper method loadAvailablePlugins.
public void loadAvailablePlugins() {
if (mLoaded) {
return;
}
List<ResolveInfo> plugins = getPlugins();
for (ResolveInfo info : plugins) {
Log.d(TAG, "Found plugin " + info);
ServiceInfo serviceInfo = info.serviceInfo;
if (serviceInfo == null) {
Log.e(TAG, "Ignore bad IM plugin: " + info);
continue;
}
String providerName = null;
String providerFullName = null;
String signUpUrl = null;
Bundle metaData = serviceInfo.metaData;
if (metaData != null) {
providerName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_NAME);
providerFullName = metaData.getString(ImPluginConstants.METADATA_PROVIDER_FULL_NAME);
signUpUrl = metaData.getString(ImPluginConstants.METADATA_SIGN_UP_URL);
}
if (TextUtils.isEmpty(providerName) || TextUtils.isEmpty(providerFullName)) {
Log.e(TAG, "Ignore bad IM plugin: " + info + ". Lack of required meta data");
continue;
}
if (isPluginDuplicated(providerName)) {
Log.e(TAG, "Ignore duplicated IM plugin: " + info);
continue;
}
if (!serviceInfo.packageName.equals(mContext.getPackageName())) {
Log.e(TAG, "Ignore plugin in package: " + serviceInfo.packageName);
continue;
}
ImPluginInfo pluginInfo = new ImPluginInfo(providerName, serviceInfo.packageName, serviceInfo.name, serviceInfo.applicationInfo.sourceDir);
ImPlugin plugin = loadPlugin(pluginInfo);
if (plugin == null) {
Log.e(TAG, "Ignore bad IM plugin");
continue;
}
try {
updateProviderDb(plugin, pluginInfo, providerFullName, signUpUrl);
} catch (SQLiteFullException e) {
Log.e(TAG, "Storage full", e);
return;
}
mPluginsInfo.add(pluginInfo);
mPluginObjects.add(plugin);
}
mLoaded = true;
}
use of android.database.sqlite.SQLiteFullException in project mobile-center-sdk-android by Microsoft.
the class DatabaseManagerTest method cursorFailsToCloseAfterPut.
@Test
public void cursorFailsToCloseAfterPut() {
/* Mocking instances. */
Context contextMock = mock(Context.class);
SQLiteOpenHelper helperMock = mock(SQLiteOpenHelper.class);
SQLiteDatabase sqLiteDatabase = mock(SQLiteDatabase.class);
when(helperMock.getWritableDatabase()).thenReturn(sqLiteDatabase);
/* Mock the select cursor we are using to find logs to evict to fail. */
mockStatic(SQLiteUtils.class);
Cursor cursor = mock(Cursor.class);
SQLiteDiskIOException exception = new SQLiteDiskIOException();
doThrow(exception).when(cursor).close();
when(cursor.moveToNext()).thenReturn(true).thenReturn(false);
SQLiteQueryBuilder sqLiteQueryBuilder = mock(SQLiteQueryBuilder.class, new Returns(cursor));
when(SQLiteUtils.newSQLiteQueryBuilder()).thenReturn(sqLiteQueryBuilder);
/* Simulate that database is full only once (will work after purging 1 log). */
when(sqLiteDatabase.insertOrThrow(anyString(), anyString(), any(ContentValues.class))).thenThrow(new SQLiteFullException()).thenReturn(1L);
/* Instantiate real instance for DatabaseManager. */
DatabaseManager databaseManager = new DatabaseManager(contextMock, "database", "table", 1, null, null, null);
databaseManager.setSQLiteOpenHelper(helperMock);
/* When we put a log, it succeeds even if a problem occurred while closing purge cursor. */
long id = databaseManager.put(mock(ContentValues.class), "priority");
assertEquals(1, id);
}
use of android.database.sqlite.SQLiteFullException in project MiMangaNu by raulhaag.
the class Database method updateMangaRead.
public static void updateMangaRead(Context context, int mid) {
ContentValues cv = new ContentValues();
cv.put(COL_LAST_READ, System.currentTimeMillis());
cv.put(COL_NEW, 0);
try {
SQLiteDatabase database = getDatabase(context);
if (!database.isReadOnly())
database.update(TABLE_MANGA, cv, COL_ID + "=" + mid, null);
else {
Log.e("Database", "(updateMangaRead) " + context.getResources().getString(R.string.error_database_is_read_only));
Util.getInstance().toast(context, context.getResources().getString(R.string.error_database_is_read_only));
}
} catch (SQLiteFullException sqlfe) {
Log.e("Database", "SQLiteFullException", sqlfe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (SQLiteDiskIOException sqldioe) {
Log.e("Database", "SQLiteDiskIOException", sqldioe);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
} catch (Exception e) {
Log.e("Database", "Exception", e);
Util.getInstance().toast(context, context.getString(R.string.error_while_trying_to_update_db));
}
}
Aggregations