@@ -77,7 +77,7 @@ public class SQLiteDatabase extends SQLiteClosable {
7777 public int status (int operation , boolean reset ){
7878 return native_status (operation , reset );
7979 }
80-
80+
8181 public static void upgradeDatabaseFormatFromVersion1To2 (File databaseToMigrate , String password ) throws Exception {
8282
8383 File newDatabasePath = null ;
@@ -90,7 +90,7 @@ public void postKey(SQLiteDatabase database){
9090 database .execSQL ("PRAGMA cipher_default_use_hmac = on" );
9191 }
9292 };
93-
93+
9494 try {
9595 newDatabasePath = File .createTempFile ("temp" , "db" , databaseToMigrate .getParentFile ());
9696 SQLiteDatabase source = SQLiteDatabase .openOrCreateDatabase (databaseToMigrate , password , null , hook );
@@ -920,15 +920,15 @@ public static SQLiteDatabase openDatabase(String path, String password, CursorFa
920920 new WeakReference <SQLiteDatabase >(sqliteDatabase ));
921921 return sqliteDatabase ;
922922 }
923-
923+
924924 public static SQLiteDatabase openOrCreateDatabase (File file , String password , CursorFactory factory , SQLiteDatabaseHook databaseHook ){
925925 return openOrCreateDatabase (file .getPath (), password , factory , databaseHook );
926926 }
927927
928928 public static SQLiteDatabase openOrCreateDatabase (String path , String password , CursorFactory factory , SQLiteDatabaseHook databaseHook ) {
929929 return openDatabase (path , password , factory , CREATE_IF_NECESSARY , databaseHook );
930930 }
931-
931+
932932 /**
933933 * Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).
934934 */
@@ -939,7 +939,7 @@ public static SQLiteDatabase openOrCreateDatabase(File file, String password, Cu
939939 /**
940940 * Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY).
941941 */
942-
942+
943943 public static SQLiteDatabase openOrCreateDatabase (String path , String password , CursorFactory factory ) {
944944 return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
945945 }
@@ -968,7 +968,7 @@ public static SQLiteDatabase create(CursorFactory factory, String password) {
968968 * Close the database.
969969 */
970970 public void close () {
971-
971+
972972 if (!isOpen ()) {
973973 return ; // already closed
974974 }
@@ -1496,7 +1496,7 @@ public Cursor rawQuery(String sql, String[] selectionArgs,
14961496 SQLiteCursor c = (SQLiteCursor )rawQueryWithFactory (
14971497 null , sql , selectionArgs , null );
14981498 c .setLoadStyle (initialRead , maxRead );
1499-
1499+
15001500 return c ;
15011501 }
15021502
@@ -1875,7 +1875,7 @@ public void rawExecSQL(String sql){
18751875 logTimeStat (sql , timeStart , null );
18761876 }
18771877 }
1878-
1878+
18791879 /**
18801880 * Execute a single SQL statement that is not a query. For example, CREATE
18811881 * TABLE, DELETE, INSERT, etc. Multiple statements separated by ;s are not
@@ -1929,7 +1929,7 @@ protected void finalize() {
19291929 public SQLiteDatabase (String path , String password , CursorFactory factory , int flags ) {
19301930 this (path , password , factory , flags , null );
19311931 }
1932-
1932+
19331933 /**
19341934 * Private constructor. See {@link #create} and {@link #openDatabase}.
19351935 *
@@ -1949,12 +1949,12 @@ public SQLiteDatabase(String path, String password, CursorFactory factory, int f
19491949 mStackTrace = new DatabaseObjectNotClosedException ().fillInStackTrace ();
19501950 mFactory = factory ;
19511951 dbopen (mPath , mFlags );
1952-
1952+
19531953 if (databaseHook != null ){
19541954 databaseHook .preKey (this );
19551955 }
1956-
1957- execSQL ( "PRAGMA key = '" + password + "'" );
1956+
1957+ native_key ( password . toCharArray () );
19581958
19591959 if (databaseHook != null ){
19601960 databaseHook .postKey (this );
@@ -2370,7 +2370,7 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
23702370 * Sets the root directory to search for the ICU data file
23712371 */
23722372 public static native void setICURoot (String path );
2373-
2373+
23742374 /**
23752375 * Native call to open the database.
23762376 *
@@ -2435,4 +2435,7 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
24352435 private native void native_rawExecSQL (String sql );
24362436
24372437 private native int native_status (int operation , boolean reset );
2438+
2439+ private native void native_key (char [] key ) throws SQLException ;
2440+ private native void native_key (String key ) throws SQLException ;
24382441}
0 commit comments