@@ -880,21 +880,87 @@ public Cursor newCursor(SQLiteDatabase db,
880880 * Call {@link #setLocale} if you would like something else.</p>
881881 *
882882 * @param path to database file to open and/or create
883+ * @param password to use to open and/or create database file
883884 * @param factory an optional factory class that is called to instantiate a
884885 * cursor when query is called, or null for default
885- * @param flags to control database access mode
886+ * @param flags to control database access mode and other options
887+ *
888+ * @return the newly opened database
889+ *
890+ * @throws SQLiteException if the database cannot be opened
891+ */
892+ public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags ) {
893+ return openDatabase (path , password .toCharArray (), factory , flags , null );
894+ }
895+
896+ /**
897+ * Open the database according to the flags {@link #OPEN_READWRITE}
898+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}.
899+ *
900+ * <p>Sets the locale of the database to the the system's current locale.
901+ * Call {@link #setLocale} if you would like something else.</p>
902+ *
903+ * @param path to database file to open and/or create
904+ * @param password to use to open and/or create database file (char array)
905+ * @param factory an optional factory class that is called to instantiate a
906+ * cursor when query is called, or null for default
907+ * @param flags to control database access mode and other options
908+ *
886909 * @return the newly opened database
910+ *
887911 * @throws SQLiteException if the database cannot be opened
888912 */
889- public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags , SQLiteDatabaseHook databaseHook ) {
890- return openDatabase (path , password . toCharArray () , factory , flags , databaseHook );
913+ public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags ) {
914+ return openDatabase (path , password , factory , flags , null );
891915 }
892916
893- public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags , SQLiteDatabaseHook databaseHook ) {
917+ /**
918+ * Open the database according to the flags {@link #OPEN_READWRITE}
919+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}
920+ * with optional hook to run on pre/post key events.
921+ *
922+ * <p>Sets the locale of the database to the the system's current locale.
923+ * Call {@link #setLocale} if you would like something else.</p>
924+ *
925+ * @param path to database file to open and/or create
926+ * @param password to use to open and/or create database file
927+ * @param factory an optional factory class that is called to instantiate a
928+ * cursor when query is called, or null for default
929+ * @param flags to control database access mode and other options
930+ * @param hook to run on pre/post key events
931+ *
932+ * @return the newly opened database
933+ *
934+ * @throws SQLiteException if the database cannot be opened
935+ */
936+ public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags , SQLiteDatabaseHook hook ) {
937+ return openDatabase (path , password .toCharArray (), factory , flags , hook );
938+ }
939+
940+ /**
941+ * Open the database according to the flags {@link #OPEN_READWRITE}
942+ * {@link #OPEN_READONLY} {@link #CREATE_IF_NECESSARY} and/or {@link #NO_LOCALIZED_COLLATORS}
943+ * with optional hook to run on pre/post key events.
944+ *
945+ * <p>Sets the locale of the database to the the system's current locale.
946+ * Call {@link #setLocale} if you would like something else.</p>
947+ *
948+ * @param path to database file to open and/or create
949+ * @param password to use to open and/or create database file (char array)
950+ * @param factory an optional factory class that is called to instantiate a
951+ * cursor when query is called, or null for default
952+ * @param flags to control database access mode and other options
953+ * @param hook to run on pre/post key events
954+ *
955+ * @return the newly opened database
956+ *
957+ * @throws SQLiteException if the database cannot be opened
958+ */
959+ public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags , SQLiteDatabaseHook hook ) {
894960 SQLiteDatabase sqliteDatabase = null ;
895961 try {
896962 // Open the database.
897- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
963+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
898964 if (SQLiteDebug .DEBUG_SQL_STATEMENTS ) {
899965 sqliteDatabase .enableSqlTracing (path );
900966 }
@@ -910,10 +976,9 @@ public static SQLiteDatabase openDatabase(String path, char[] password, CursorFa
910976 // delete is only for non-memory database files
911977 new File (path ).delete ();
912978 }
913- sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , databaseHook );
979+ sqliteDatabase = new SQLiteDatabase (path , password , factory , flags , hook );
914980 }
915- ActiveDatabases .getInstance ().mActiveDatabases .add (
916- new WeakReference <SQLiteDatabase >(sqliteDatabase ));
981+ ActiveDatabases .getInstance ().mActiveDatabases .add (new WeakReference <SQLiteDatabase >(sqliteDatabase ));
917982 return sqliteDatabase ;
918983 }
919984
@@ -948,14 +1013,6 @@ public static SQLiteDatabase openOrCreateDatabase(String path, char[] password,
9481013 return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
9491014 }
9501015
951- public static SQLiteDatabase openDatabase (String path , String password , CursorFactory factory , int flags ) {
952- return openDatabase (path , password .toCharArray (), factory , CREATE_IF_NECESSARY , null );
953- }
954-
955- public static SQLiteDatabase openDatabase (String path , char [] password , CursorFactory factory , int flags ) {
956- return openDatabase (path , password , factory , CREATE_IF_NECESSARY , null );
957- }
958-
9591016 /**
9601017 * Create a memory backed SQLite database. Its contents will be destroyed
9611018 * when the database is closed.
0 commit comments