Skip to content

Commit d82a49e

Browse files
Create parent 'databases' directory if it doesn't exist
1 parent 82b4217 commit d82a49e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,18 @@ private SQLiteDatabase getDatabaseLocked(boolean writable) {
325325
db = SQLiteDatabase.create(null);
326326
} else {
327327
try {
328-
final String path = mContext.getDatabasePath(mName).getPath();
328+
final File filePath = mContext.getDatabasePath(mName);
329+
final String path = filePath.getPath();
330+
/*
331+
Modified by Zetetic, newer Android OS versions will create the
332+
databases directory upon installation of the APK, whereas older
333+
versions, such as some devices running API 21 the databases directory
334+
does not exist.
335+
*/
336+
final File databasesDirectory = new File(filePath.getParent());
337+
if(!databasesDirectory.exists()){
338+
databasesDirectory.mkdirs();
339+
}
329340
/*
330341
Modified by Zetetic to support propagation of the mEnableWriteAheadLogging
331342
should a user invoke setWriteAheadLoggingEnabled() when the mDatabase

0 commit comments

Comments
 (0)