Skip to content

Commit

Permalink
Changing the process for using a system provided ICU dat file or extr…
Browse files Browse the repository at this point in the history
…acting one from assets
  • Loading branch information
developernotes committed Dec 28, 2011
1 parent f4c818c commit 389f716
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/info/guardianproject/database/sqlcipher/SQLiteDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ private static void loadICUData(Context context) {
File applicationFilesDirectory = context.getFilesDir();
File icuDir = new File(applicationFilesDirectory, "icu");
if(!icuDir.exists()) icuDir.mkdirs();
File icuDataFile = new File(icuDir, "icudt44l.dat");
File icuDataFile = new File(icuDir, "icudt46l.dat");
if(!icuDataFile.exists()) {
ZipInputStream in = new ZipInputStream(context.getAssets().open("icudt44l.zip"));
ZipInputStream in = new ZipInputStream(context.getAssets().open("icudt46l.zip"));
in.getNextEntry();

OutputStream out = new FileOutputStream(icuDataFile);
Expand All @@ -104,12 +104,13 @@ public static void loadLibs (Context context)
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 = android.os.Build.VERSION.SDK_INT < 9 ? applicationFilesDirectory.getAbsolutePath()
: "/system/usr";
String icuRootPath = systemICUFileExists ? "/system/usr" : applicationFilesDirectory.getAbsolutePath();
setICURoot(icuRootPath);
if(android.os.Build.VERSION.SDK_INT < 9){

if(!systemICUFileExists){
loadICUData(context);
}
}
Expand Down Expand Up @@ -917,6 +918,7 @@ public static SQLiteDatabase create(CursorFactory factory, String password) {
* Close the database.
*/
public void close() {

if (!isOpen()) {
return; // already closed
}
Expand Down

0 comments on commit 389f716

Please sign in to comment.