@@ -864,21 +864,87 @@ public Cursor newCursor(SQLiteDatabase db,
864
864
* Call {@link #setLocale} if you would like something else.</p>
865
865
*
866
866
* @param path to database file to open and/or create
867
+ * @param password to use to open and/or create database file
867
868
* @param factory an optional factory class that is called to instantiate a
868
869
* cursor when query is called, or null for default
869
- * @param flags to control database access mode
870
+ * @param flags to control database access mode and other options
871
+ *
872
+ * @return the newly opened database
873
+ *
874
+ * @throws SQLiteException if the database cannot be opened
875
+ */
876
+ public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags ) {
877
+ return openDatabase (path , password .toCharArray (), factory , flags , null );
878
+ }
879
+
880
+ /**
881
+ * Open the database according to the flags {@link #OPEN_READWRITE}
882
+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.
883
+ *
884
+ * <p>Sets the locale of the database to the the system's current locale.
885
+ * Call {@link #setLocale} if you would like something else.</p>
886
+ *
887
+ * @param path to database file to open and/or create
888
+ * @param password to use to open and/or create database file (char array)
889
+ * @param factory an optional factory class that is called to instantiate a
890
+ * cursor when query is called, or null for default
891
+ * @param flags to control database access mode and other options
892
+ *
870
893
* @return the newly opened database
894
+ *
871
895
* @throws SQLiteException if the database cannot be opened
872
896
*/
873
- public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags , SQLiteDatabaseHook databaseHook ) {
874
- return openDatabase (path , password . toCharArray () , factory , flags , databaseHook );
897
+ public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags ) {
898
+ return openDatabase (path , password , factory , flags , null );
875
899
}
876
900
877
- public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags , SQLiteDatabaseHook databaseHook ) {
901
+ /**
902
+ * Open the database according to the flags {@link #OPEN_READWRITE}
903
+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}
904
+ * with optional hook to run on pre/post key events.
905
+ *
906
+ * <p>Sets the locale of the database to the the system's current locale.
907
+ * Call {@link #setLocale} if you would like something else.</p>
908
+ *
909
+ * @param path to database file to open and/or create
910
+ * @param password to use to open and/or create database file
911
+ * @param factory an optional factory class that is called to instantiate a
912
+ * cursor when query is called, or null for default
913
+ * @param flags to control database access mode and other options
914
+ * @param hook to run on pre/post key events
915
+ *
916
+ * @return the newly opened database
917
+ *
918
+ * @throws SQLiteException if the database cannot be opened
919
+ */
920
+ public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags , SQLiteDatabaseHook hook ) {
921
+ return openDatabase (path , password .toCharArray (), factory , flags , hook );
922
+ }
923
+
924
+ /**
925
+ * Open the database according to the flags {@link #OPEN_READWRITE}
926
+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}
927
+ * with optional hook to run on pre/post key events.
928
+ *
929
+ * <p>Sets the locale of the database to the the system's current locale.
930
+ * Call {@link #setLocale} if you would like something else.</p>
931
+ *
932
+ * @param path to database file to open and/or create
933
+ * @param password to use to open and/or create database file (char array)
934
+ * @param factory an optional factory class that is called to instantiate a
935
+ * cursor when query is called, or null for default
936
+ * @param flags to control database access mode and other options
937
+ * @param hook to run on pre/post key events
938
+ *
939
+ * @return the newly opened database
940
+ *
941
+ * @throws SQLiteException if the database cannot be opened
942
+ */
943
+ public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags , SQLiteDatabaseHook hook ) {
878
944
SQLiteDatabase sqliteDatabase = null ;
879
945
try {
880
946
// Open the database.
881
- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
947
+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
882
948
if (SQLiteDebug .DEBUG_SQL_STATEMENTS ) {
883
949
sqliteDatabase .enableSqlTracing (path );
884
950
}
@@ -894,10 +960,9 @@ public static SQLiteDatabase openDatabase(String path, char[] password, CursorFa
894
960
// delete is only for non-memory database files
895
961
new File (path ).delete ();
896
962
}
897
- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
963
+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
898
964
}
899
- ActiveDatabases .getInstance ().mActiveDatabases .add (
900
- new WeakReference <SQLiteDatabase >(sqliteDatabase ));
965
+ ActiveDatabases .getInstance ().mActiveDatabases .add (new WeakReference <SQLiteDatabase >(sqliteDatabase ));
901
966
return sqliteDatabase ;
902
967
}
903
968
@@ -932,14 +997,6 @@ public static SQLiteDatabase openOrCreateDatabase(String path, char[] password,
932
997
return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
933
998
}
934
999
935
- public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags ) {
936
- return openDatabase (path , password .toCharArray (), factory , CREATE_IF_NECESSARY , null );
937
- }
938
-
939
- public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags ) {
940
- return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
941
- }
942
-
943
1000
/**
944
1001
* Create a memory backed SQLite database. Its contents will be destroyed
945
1002
* when the database is closed.
0 commit comments