Coder Social home page Coder Social logo

Comments (8)

jeffdcamp avatar jeffdcamp commented on August 15, 2024

Here is a very simple patch that will fix this issue and it is backwards compatible. I applied it and tested it against the v2 branch.


--- src/net/sqlcipher/database/SQLiteDatabase.java  (revision 2a7b24d6eecc6b8ff2ccffbe2a0d4d745ea5ace0)
+++ src/net/sqlcipher/database/SQLiteDatabase.java  (revision )
@@ -103,11 +103,10 @@
         }
     }
 
-    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()) {
@@ -130,19 +129,23 @@
         }
     }
 
-    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);
         }
     }

from android-database-sqlcipher.

developernotes avatar developernotes commented on August 15, 2024

Hi jeffdcamp,

Thanks for taking a look at this. Would you mind sending a pull request for the change? Thanks!

from android-database-sqlcipher.

jeffdcamp avatar jeffdcamp commented on August 15, 2024

I just submitted 2 pull requests for the change.... one for master (version 1.1) and one for v2 (2.0)

from android-database-sqlcipher.

developernotes avatar developernotes commented on August 15, 2024

Hi jeffdcamp,

Thanks for submitting that. I'll review it this afternoon and if everything runs smooth with our test suite I will merge it into the v2 branch. v2 will be merged back into master soon so no need for the extra pull request. Thanks again!

from android-database-sqlcipher.

jeffdcamp avatar jeffdcamp commented on August 15, 2024

I know this is not the place for this comment.... but is there a developer group that I can post comments/questions to? (I'm concerned about compatibility/migration from v1.1 to v2.0... my 1.1 database didn't seem to open when I compiled v2 branch and tried to open an existing 1.1 database using v2 code)

from android-database-sqlcipher.

developernotes avatar developernotes commented on August 15, 2024

Hi jeffdcamp,

There is a difference between the database format in 2.0 vs. 1.1. I have added a upgrade method in v2 called SQLiteDatabase.upgradeDatabaseFormatFromVersion1To2 to perform the upgrade. If you need to maintain the 1.1 format but want to use the 2.0 library I have also added a SQLiteDatabaseHook interface that you can pass into the SQLDatabase.openOrCreateDatabase method which will allow you to open a 1.1 database without issues/upgrading with the 2.0 sqlcipher core. Note this is only available in the v2 branch. To do something like that it would look like:

SQLiteDatabaseHook hook = new SQLiteDatabaseHook(){
  public void preKey(SQLiteDatabase database){
    database.rawExecSQL("PRAGMA cipher_default_use_hmac = off");
  }
  public void postKey(SQLiteDatabase database){}
}

SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databasePath, 
                                                              password, null, hook);

from android-database-sqlcipher.

jeffdcamp avatar jeffdcamp commented on August 15, 2024

FYI... I've been using this feature ("ICU dat file on SD card") in 2.0RC5 for quite some time and on many devices using many different versions of Android and this has been working great.

Jeff

from android-database-sqlcipher.

developernotes avatar developernotes commented on August 15, 2024

Jeff,

Glad to hear it's working well for you, thanks for reporting back!

from android-database-sqlcipher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.