Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78526012 authored by Vasu Nori's avatar Vasu Nori Committed by Android (Google) Code Review
Browse files

Merge "treat "can't open database file error" as "database corruption error""

parents 6b1f6e6a c7fe777d
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -991,8 +991,10 @@ public class SQLiteDatabase extends SQLiteClosable {
            }
            }
            return db;
            return db;
        } catch (SQLiteDatabaseCorruptException e) {
        } catch (SQLiteDatabaseCorruptException e) {
            db.mErrorHandler.onCorruption(db);
            return handleCorruptedDatabase(db, path, factory, flags, errorHandler);
            return SQLiteDatabase.openDatabase(path, factory, flags, errorHandler);
        } catch (SQLiteCantOpenDatabaseException e) {
            Log.e(TAG, "database file can't be opened. possibly due to database corruption.");
            return handleCorruptedDatabase(db, path, factory, flags, errorHandler);
        } catch (SQLiteException e) {
        } catch (SQLiteException e) {
            Log.e(TAG, "Failed to open the database. closing it.", e);
            Log.e(TAG, "Failed to open the database. closing it.", e);
            db.close();
            db.close();
@@ -1000,6 +1002,12 @@ public class SQLiteDatabase extends SQLiteClosable {
        }
        }
    }
    }


    private static SQLiteDatabase handleCorruptedDatabase(SQLiteDatabase db, String path,
            CursorFactory factory, int flags, DatabaseErrorHandler errorHandler) {
        db.mErrorHandler.onCorruption(db);
        return SQLiteDatabase.openDatabase(path, factory, flags, errorHandler);
    }

    /**
    /**
     * Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).
     * Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).
     */
     */