Skip to content

Commit 28edeed

Browse files
Remove initial opening with OPEN_READONLY when requested not writable for consistency with AOSP upstream
1 parent 1917acc commit 28edeed

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

sqlcipher/src/main/java/net/zetetic/database/sqlcipher/SQLiteOpenHelper.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,21 @@ private SQLiteDatabase getDatabaseLocked(boolean writable) {
322322
db = SQLiteDatabase.create(null);
323323
} else {
324324
try {
325-
if (DEBUG_STRICT_READONLY && !writable) {
326-
final String path = mContext.getDatabasePath(mName).getPath();
327-
db = SQLiteDatabase.openDatabase(path, mPassword, mFactory,
328-
SQLiteDatabase.OPEN_READONLY, mErrorHandler, mDatabaseHook);
329-
} else {
330-
/*
331-
Modified by Zetetic to support propagation of the mEnableWriteAheadLogging
332-
should a user invoke setWriteAheadLoggingEnabled() when the mDatabase
333-
instance has not yet been created via getWritableDatabase(). This allows
334-
setWriteAheadLoggingEnabled() to be set in the constructor of a
335-
SQLiteOpenHelper subclass.
336-
*/
337-
int flags = SQLiteDatabase.CREATE_IF_NECESSARY;
338-
if(mEnableWriteAheadLogging) {
339-
flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
340-
}
341-
db = SQLiteDatabase.openDatabase(
342-
mName, mPassword, mFactory, flags, mErrorHandler, mDatabaseHook
343-
);
325+
final String path = mContext.getDatabasePath(mName).getPath();
326+
/*
327+
Modified by Zetetic to support propagation of the mEnableWriteAheadLogging
328+
should a user invoke setWriteAheadLoggingEnabled() when the mDatabase
329+
instance has not yet been created via getWritableDatabase(). This allows
330+
setWriteAheadLoggingEnabled() to be set in the constructor of a
331+
SQLiteOpenHelper subclass.
332+
*/
333+
int flags = SQLiteDatabase.CREATE_IF_NECESSARY;
334+
if(mEnableWriteAheadLogging) {
335+
flags |= SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING;
344336
}
337+
db = SQLiteDatabase.openDatabase(
338+
path, mPassword, mFactory, flags, mErrorHandler, mDatabaseHook
339+
);
345340
} catch (SQLiteException ex) {
346341
if (writable) {
347342
throw ex;

0 commit comments

Comments
 (0)