@@ -82,12 +82,40 @@ public int status(int operation, boolean reset){
82
82
return native_status (operation , reset );
83
83
}
84
84
85
+ /**
86
+ * Change the password of the open database using sqlite3_rekey().
87
+ *
88
+ * @param password new database password
89
+ *
90
+ * @throws SQLiteException if there is an issue changing the password internally
91
+ * OR if the database is not open
92
+ *
93
+ * FUTURE @todo throw IllegalStateException if the database is not open and
94
+ * update the test suite
95
+ */
85
96
public void changePassword (String password ) throws SQLiteException {
86
- native_rekey (password );
97
+ if (!isOpen ()) {
98
+ throw new SQLiteException ("database not open" );
99
+ }
100
+ native_rekey (password );
87
101
}
88
102
103
+ /**
104
+ * Change the password of the open database using sqlite3_rekey().
105
+ *
106
+ * @param password new database password (char array)
107
+ *
108
+ * @throws SQLiteException if there is an issue changing the password internally
109
+ * OR if the database is not open
110
+ *
111
+ * FUTURE @todo throw IllegalStateException if the database is not open and
112
+ * update the test suite
113
+ */
89
114
public void changePassword (char [] password ) throws SQLiteException {
90
- native_rekey (password );
115
+ if (!isOpen ()) {
116
+ throw new SQLiteException ("database not open" );
117
+ }
118
+ native_rekey (password );
91
119
}
92
120
93
121
private static void loadICUData (Context context , File workingDir ) {
@@ -2655,7 +2683,7 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
2655
2683
2656
2684
private native void native_key (char [] key ) throws SQLException ;
2657
2685
private native void native_key (String key ) throws SQLException ;
2658
-
2686
+
2659
2687
private native void native_rekey (String key ) throws SQLException ;
2660
2688
private native void native_rekey (char [] key ) throws SQLException ;
2661
2689
}
0 commit comments