@@ -77,7 +77,7 @@ public class SQLiteDatabase extends SQLiteClosable {
77
77
public int status (int operation , boolean reset ){
78
78
return native_status (operation , reset );
79
79
}
80
-
80
+
81
81
public static void upgradeDatabaseFormatFromVersion1To2 (File databaseToMigrate , String password ) throws Exception {
82
82
83
83
File newDatabasePath = null ;
@@ -90,7 +90,7 @@ public void postKey(SQLiteDatabase database){
90
90
database .execSQL ("PRAGMA cipher_default_use_hmac = on" );
91
91
}
92
92
};
93
-
93
+
94
94
try {
95
95
newDatabasePath = File .createTempFile ("temp" , "db" , databaseToMigrate .getParentFile ());
96
96
SQLiteDatabase source = SQLiteDatabase .openOrCreateDatabase (databaseToMigrate , password , null , hook );
@@ -920,15 +920,15 @@ public static SQLiteDatabase openDatabase(String path, String password, CursorFa
920
920
new WeakReference <SQLiteDatabase >(sqliteDatabase ));
921
921
return sqliteDatabase ;
922
922
}
923
-
923
+
924
924
public static SQLiteDatabase openOrCreateDatabase (File file , String password , CursorFactory factory , SQLiteDatabaseHook databaseHook ){
925
925
return openOrCreateDatabase (file .getPath (), password , factory , databaseHook );
926
926
}
927
927
928
928
public static SQLiteDatabase openOrCreateDatabase (String path , String password , CursorFactory factory , SQLiteDatabaseHook databaseHook ) {
929
929
return openDatabase (path , password , factory , CREATE_IF_NECESSARY , databaseHook );
930
930
}
931
-
931
+
932
932
/**
933
933
* Equivalent to openDatabase(file.getPath(), factory, CREATE_IF_NECESSARY).
934
934
*/
@@ -939,7 +939,7 @@ public static SQLiteDatabase openOrCreateDatabase(File file, String password, Cu
939
939
/**
940
940
* Equivalent to openDatabase(path, factory, CREATE_IF_NECESSARY).
941
941
*/
942
-
942
+
943
943
public static SQLiteDatabase openOrCreateDatabase (String path , String password , CursorFactory factory ) {
944
944
return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
945
945
}
@@ -968,7 +968,7 @@ public static SQLiteDatabase create(CursorFactory factory, String password) {
968
968
* Close the database.
969
969
*/
970
970
public void close () {
971
-
971
+
972
972
if (!isOpen ()) {
973
973
return ; // already closed
974
974
}
@@ -1496,7 +1496,7 @@ public Cursor rawQuery(String sql, String[] selectionArgs,
1496
1496
SQLiteCursor c = (SQLiteCursor )rawQueryWithFactory (
1497
1497
null , sql , selectionArgs , null );
1498
1498
c .setLoadStyle (initialRead , maxRead );
1499
-
1499
+
1500
1500
return c ;
1501
1501
}
1502
1502
@@ -1875,7 +1875,7 @@ public void rawExecSQL(String sql){
1875
1875
logTimeStat (sql , timeStart , null );
1876
1876
}
1877
1877
}
1878
-
1878
+
1879
1879
/**
1880
1880
* Execute a single SQL statement that is not a query. For example, CREATE
1881
1881
* TABLE, DELETE, INSERT, etc. Multiple statements separated by ;s are not
@@ -1929,7 +1929,7 @@ protected void finalize() {
1929
1929
public SQLiteDatabase (String path , String password , CursorFactory factory , int flags ) {
1930
1930
this (path , password , factory , flags , null );
1931
1931
}
1932
-
1932
+
1933
1933
/**
1934
1934
* Private constructor. See {@link #create} and {@link #openDatabase}.
1935
1935
*
@@ -1949,12 +1949,12 @@ public SQLiteDatabase(String path, String password, CursorFactory factory, int f
1949
1949
mStackTrace = new DatabaseObjectNotClosedException ().fillInStackTrace ();
1950
1950
mFactory = factory ;
1951
1951
dbopen (mPath , mFlags );
1952
-
1952
+
1953
1953
if (databaseHook != null ){
1954
1954
databaseHook .preKey (this );
1955
1955
}
1956
-
1957
- execSQL ( "PRAGMA key = '" + password + "'" );
1956
+
1957
+ native_key ( password . toCharArray () );
1958
1958
1959
1959
if (databaseHook != null ){
1960
1960
databaseHook .postKey (this );
@@ -2370,7 +2370,7 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
2370
2370
* Sets the root directory to search for the ICU data file
2371
2371
*/
2372
2372
public static native void setICURoot (String path );
2373
-
2373
+
2374
2374
/**
2375
2375
* Native call to open the database.
2376
2376
*
@@ -2435,4 +2435,7 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
2435
2435
private native void native_rawExecSQL (String sql );
2436
2436
2437
2437
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 ;
2438
2441
}
0 commit comments