@@ -864,21 +864,87 @@ public Cursor newCursor(SQLiteDatabase db,
864864 * Call {@link #setLocale} if you would like something else.</p>
865865 *
866866 * @param path to database file to open and/or create
867+ * @param password to use to open and/or create database file
867868 * @param factory an optional factory class that is called to instantiate a
868869 * 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+ *
870893 * @return the newly opened database
894+ *
871895 * @throws SQLiteException if the database cannot be opened
872896 */
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 );
875899 }
876900
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 ) {
878944 SQLiteDatabase sqliteDatabase = null ;
879945 try {
880946 // Open the database.
881- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
947+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
882948 if (SQLiteDebug .DEBUG_SQL_STATEMENTS ) {
883949 sqliteDatabase .enableSqlTracing (path );
884950 }
@@ -894,10 +960,9 @@ public static SQLiteDatabase openDatabase(String path, char[] password, CursorFa
894960 // delete is only for non-memory database files
895961 new File (path ).delete ();
896962 }
897- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
963+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
898964 }
899- ActiveDatabases .getInstance ().mActiveDatabases .add (
900- new WeakReference <SQLiteDatabase >(sqliteDatabase ));
965+ ActiveDatabases .getInstance ().mActiveDatabases .add (new WeakReference <SQLiteDatabase >(sqliteDatabase ));
901966 return sqliteDatabase ;
902967 }
903968
@@ -932,14 +997,6 @@ public static SQLiteDatabase openOrCreateDatabase(String path, char[] password,
932997 return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
933998 }
934999
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-
9431000 /**
9441001 * Create a memory backed SQLite database. Its contents will be destroyed
9451002 * when the database is closed.
0 commit comments