Skip to content

Fix for "ICU dat file on SD card" #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/info/guardianproject/database/sqlcipher/SQLiteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ public class SQLiteDatabase extends SQLiteClosable {
private static final int EVENT_DB_OPERATION = 52000;
private static final int EVENT_DB_CORRUPT = 75004;

private static void loadICUData(Context context) {
private static void loadICUData(Context context, File workingDir) {

try {
File applicationFilesDirectory = context.getFilesDir();
File icuDir = new File(applicationFilesDirectory, "icu");
File icuDir = new File(workingDir, "icu");
if(!icuDir.exists()) icuDir.mkdirs();
File icuDataFile = new File(icuDir, "icudt46l.dat");
if(!icuDataFile.exists()) {
Expand All @@ -99,19 +98,23 @@ private static void loadICUData(Context context) {
}
}

public static void loadLibs (Context context)
public static void loadLibs (Context context) {
loadLibs(context, context.getFilesDir());
}

public static void loadLibs (Context context, File workingDir)
{
System.loadLibrary("stlport_shared");
System.loadLibrary("sqlcipher_android");
System.loadLibrary("database_sqlcipher");

boolean systemICUFileExists = new File("/system/usr/icu/icudt46l.dat").exists();
File applicationFilesDirectory = context.getFilesDir();
String icuRootPath = systemICUFileExists ? "/system/usr" : applicationFilesDirectory.getAbsolutePath();

String icuRootPath = systemICUFileExists ? "/system/usr" : workingDir.getAbsolutePath();
setICURoot(icuRootPath);

if(!systemICUFileExists){
loadICUData(context);
loadICUData(context, workingDir);
}
}

Expand Down