Skip to content

Commit 7710fab

Browse files
Merge pull request #51 from jeffdcamp/v2
Fix for ICU dat file on SD card
2 parents 2a7b24d + 745b88c commit 7710fab

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ public void postKey(SQLiteDatabase database){
103103
}
104104
}
105105

106-
private static void loadICUData(Context context) {
107-
106+
private static void loadICUData(Context context, File workingDir) {
107+
108108
try {
109-
File applicationFilesDirectory = context.getFilesDir();
110-
File icuDir = new File(applicationFilesDirectory, "icu");
109+
File icuDir = new File(workingDir, "icu");
111110
if(!icuDir.exists()) icuDir.mkdirs();
112111
File icuDataFile = new File(icuDir, "icudt46l.dat");
113112
if(!icuDataFile.exists()) {
@@ -130,19 +129,23 @@ private static void loadICUData(Context context) {
130129
}
131130
}
132131

133-
public static void loadLibs (Context context)
132+
public static void loadLibs (Context context) {
133+
loadLibs(context, context.getFilesDir());
134+
}
135+
136+
public static void loadLibs (Context context, File workingDir)
134137
{
135138
System.loadLibrary("stlport_shared");
136139
System.loadLibrary("sqlcipher_android");
137140
System.loadLibrary("database_sqlcipher");
138141

139142
boolean systemICUFileExists = new File("/system/usr/icu/icudt46l.dat").exists();
140-
File applicationFilesDirectory = context.getFilesDir();
141-
String icuRootPath = systemICUFileExists ? "/system/usr" : applicationFilesDirectory.getAbsolutePath();
143+
144+
String icuRootPath = systemICUFileExists ? "/system/usr" : workingDir.getAbsolutePath();
142145
setICURoot(icuRootPath);
143146

144147
if(!systemICUFileExists){
145-
loadICUData(context);
148+
loadICUData(context, workingDir);
146149
}
147150
}
148151

0 commit comments

Comments
 (0)