Java Code Examples for android.database.sqlite.SQLiteCantOpenDatabaseException

The following examples show how to use android.database.sqlite.SQLiteCantOpenDatabaseException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: OpenXiaomiScale   Source File: Database.java    License: Apache License 2.0 6 votes vote down vote up
private boolean existsDatabase()
{
	SQLiteDatabase database = null;
	boolean isExist = true;

	try
	{
		database = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READONLY);
	}
	catch (SQLiteCantOpenDatabaseException e)
	{
		// No database
		Log.d("Database", "Database not found!");
		isExist = false;
	}
	finally
	{
		if ( database != null )
			database.close();
	}

	return isExist;
}
 
Example 2
Source Project: android-job   Source File: JobStorage.java    License: Apache License 2.0 6 votes vote down vote up
@NonNull
@VisibleForTesting
/*package*/ SQLiteDatabase getDatabase() {
    if (mInjectedDatabase != null) {
        return mInjectedDatabase;
    } else {
        try {
            return mDbHelper.getWritableDatabase();

        } catch (SQLiteCantOpenDatabaseException e) {
            CAT.e(e);

            // that's bad, delete the database and try again, otherwise users may get stuck in a loop
            new JobStorageDatabaseErrorHandler().deleteDatabaseFile(DATABASE_NAME);
            return mDbHelper.getWritableDatabase();
        }
    }
}
 
Example 3
Source Project: braintree_android   Source File: AnalyticsDatabaseUnitTest.java    License: MIT License 4 votes vote down vote up
@Override
public SQLiteDatabase getReadableDatabase() {
    throw new SQLiteCantOpenDatabaseException();
}
 
Example 4
Source Project: braintree_android   Source File: AnalyticsDatabaseUnitTest.java    License: MIT License 4 votes vote down vote up
@Override
public SQLiteDatabase getWritableDatabase() {
    throw new SQLiteCantOpenDatabaseException();
}