1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.database.sqlite; 18 19 import android.annotation.IntRange; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 import android.compat.annotation.UnsupportedAppUsage; 23 import android.content.Context; 24 import android.database.DatabaseErrorHandler; 25 import android.database.SQLException; 26 import android.database.sqlite.SQLiteDatabase.CursorFactory; 27 import android.os.FileUtils; 28 import android.util.Log; 29 30 import java.io.File; 31 import java.util.Objects; 32 33 /** 34 * A helper class to manage database creation and version management. 35 * 36 * <p>You create a subclass implementing {@link #onCreate}, {@link #onUpgrade} and 37 * optionally {@link #onOpen}, and this class takes care of opening the database 38 * if it exists, creating it if it does not, and upgrading it as necessary. 39 * Transactions are used to make sure the database is always in a sensible state. 40 * 41 * <p>This class makes it easy for {@link android.content.ContentProvider} 42 * implementations to defer opening and upgrading the database until first use, 43 * to avoid blocking application startup with long-running database upgrades. 44 * 45 * <p>For an example, see the NotePadProvider class in the NotePad sample application, 46 * in the <em>samples/</em> directory of the SDK.</p> 47 * 48 * <p class="note"><strong>Note:</strong> this class assumes 49 * monotonically increasing version numbers for upgrades.</p> 50 * 51 * <p class="note"><strong>Note:</strong> the {@link AutoCloseable} interface was 52 * first added in the {@link android.os.Build.VERSION_CODES#Q} release.</p> 53 */ 54 public abstract class SQLiteOpenHelper implements AutoCloseable { 55 private static final String TAG = SQLiteOpenHelper.class.getSimpleName(); 56 57 private final Context mContext; 58 @UnsupportedAppUsage 59 private final String mName; 60 private final int mNewVersion; 61 private final int mMinimumSupportedVersion; 62 63 private SQLiteDatabase mDatabase; 64 private boolean mIsInitializing; 65 private SQLiteDatabase.OpenParams.Builder mOpenParamsBuilder; 66 67 /** 68 * Create a helper object to create, open, and/or manage a database. 69 * This method always returns very quickly. The database is not actually 70 * created or opened until one of {@link #getWritableDatabase} or 71 * {@link #getReadableDatabase} is called. 72 * 73 * @param context to use for locating paths to the the database 74 * @param name of the database file, or null for an in-memory database 75 * @param factory to use for creating cursor objects, or null for the default 76 * @param version number of the database (starting at 1); if the database is older, 77 * {@link #onUpgrade} will be used to upgrade the database; if the database is 78 * newer, {@link #onDowngrade} will be used to downgrade the database 79 */ SQLiteOpenHelper(@ullable Context context, @Nullable String name, @Nullable CursorFactory factory, int version)80 public SQLiteOpenHelper(@Nullable Context context, @Nullable String name, 81 @Nullable CursorFactory factory, int version) { 82 this(context, name, factory, version, null); 83 } 84 85 /** 86 * Create a helper object to create, open, and/or manage a database. 87 * The database is not actually created or opened until one of 88 * {@link #getWritableDatabase} or {@link #getReadableDatabase} is called. 89 * 90 * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be 91 * used to handle corruption when sqlite reports database corruption.</p> 92 * 93 * @param context to use for locating paths to the the database 94 * @param name of the database file, or null for an in-memory database 95 * @param factory to use for creating cursor objects, or null for the default 96 * @param version number of the database (starting at 1); if the database is older, 97 * {@link #onUpgrade} will be used to upgrade the database; if the database is 98 * newer, {@link #onDowngrade} will be used to downgrade the database 99 * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database 100 * corruption, or null to use the default error handler. 101 */ SQLiteOpenHelper(@ullable Context context, @Nullable String name, @Nullable CursorFactory factory, int version, @Nullable DatabaseErrorHandler errorHandler)102 public SQLiteOpenHelper(@Nullable Context context, @Nullable String name, 103 @Nullable CursorFactory factory, int version, 104 @Nullable DatabaseErrorHandler errorHandler) { 105 this(context, name, factory, version, 0, errorHandler); 106 } 107 108 /** 109 * Create a helper object to create, open, and/or manage a database. 110 * This method always returns very quickly. The database is not actually 111 * created or opened until one of {@link #getWritableDatabase} or 112 * {@link #getReadableDatabase} is called. 113 * 114 * @param context to use for locating paths to the the database 115 * @param name of the database file, or null for an in-memory database 116 * @param version number of the database (starting at 1); if the database is older, 117 * {@link #onUpgrade} will be used to upgrade the database; if the database is 118 * newer, {@link #onDowngrade} will be used to downgrade the database 119 * @param openParams configuration parameters that are used for opening {@link SQLiteDatabase}. 120 * Please note that {@link SQLiteDatabase#CREATE_IF_NECESSARY} flag will always be 121 * set when the helper opens the database 122 */ SQLiteOpenHelper(@ullable Context context, @Nullable String name, int version, @NonNull SQLiteDatabase.OpenParams openParams)123 public SQLiteOpenHelper(@Nullable Context context, @Nullable String name, int version, 124 @NonNull SQLiteDatabase.OpenParams openParams) { 125 this(context, name, version, 0, openParams.toBuilder()); 126 } 127 128 /** 129 * Same as {@link #SQLiteOpenHelper(Context, String, CursorFactory, int, DatabaseErrorHandler)} 130 * but also accepts an integer minimumSupportedVersion as a convenience for upgrading very old 131 * versions of this database that are no longer supported. If a database with older version that 132 * minimumSupportedVersion is found, it is simply deleted and a new database is created with the 133 * given name and version 134 * 135 * @param context to use for locating paths to the the database 136 * @param name the name of the database file, null for a temporary in-memory database 137 * @param factory to use for creating cursor objects, null for default 138 * @param version the required version of the database 139 * @param minimumSupportedVersion the minimum version that is supported to be upgraded to 140 * {@code version} via {@link #onUpgrade}. If the current database version is lower 141 * than this, database is simply deleted and recreated with the version passed in 142 * {@code version}. {@link #onBeforeDelete} is called before deleting the database 143 * when this happens. This is 0 by default. 144 * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database 145 * corruption, or null to use the default error handler. 146 * @see #onBeforeDelete(SQLiteDatabase) 147 * @see #SQLiteOpenHelper(Context, String, CursorFactory, int, DatabaseErrorHandler) 148 * @see #onUpgrade(SQLiteDatabase, int, int) 149 * @hide 150 */ SQLiteOpenHelper(@ullable Context context, @Nullable String name, @Nullable CursorFactory factory, int version, int minimumSupportedVersion, @Nullable DatabaseErrorHandler errorHandler)151 public SQLiteOpenHelper(@Nullable Context context, @Nullable String name, 152 @Nullable CursorFactory factory, int version, 153 int minimumSupportedVersion, @Nullable DatabaseErrorHandler errorHandler) { 154 this(context, name, version, minimumSupportedVersion, 155 new SQLiteDatabase.OpenParams.Builder()); 156 mOpenParamsBuilder.setCursorFactory(factory); 157 mOpenParamsBuilder.setErrorHandler(errorHandler); 158 } 159 SQLiteOpenHelper(@ullable Context context, @Nullable String name, int version, int minimumSupportedVersion, @NonNull SQLiteDatabase.OpenParams.Builder openParamsBuilder)160 private SQLiteOpenHelper(@Nullable Context context, @Nullable String name, int version, 161 int minimumSupportedVersion, 162 @NonNull SQLiteDatabase.OpenParams.Builder openParamsBuilder) { 163 Objects.requireNonNull(openParamsBuilder); 164 if (version < 1) throw new IllegalArgumentException("Version must be >= 1, was " + version); 165 166 mContext = context; 167 mName = name; 168 mNewVersion = version; 169 mMinimumSupportedVersion = Math.max(0, minimumSupportedVersion); 170 setOpenParamsBuilder(openParamsBuilder); 171 } 172 173 /** 174 * Return the name of the SQLite database being opened, as given to 175 * the constructor. 176 */ getDatabaseName()177 public String getDatabaseName() { 178 return mName; 179 } 180 181 /** 182 * Enables or disables the use of write-ahead logging for the database. 183 * 184 * Write-ahead logging cannot be used with read-only databases so the value of 185 * this flag is ignored if the database is opened read-only. 186 * 187 * @param enabled True if write-ahead logging should be enabled, false if it 188 * should be disabled. 189 * 190 * @see SQLiteDatabase#enableWriteAheadLogging() 191 */ setWriteAheadLoggingEnabled(boolean enabled)192 public void setWriteAheadLoggingEnabled(boolean enabled) { 193 synchronized (this) { 194 if (mOpenParamsBuilder.isWriteAheadLoggingEnabled() != enabled) { 195 if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) { 196 if (enabled) { 197 mDatabase.enableWriteAheadLogging(); 198 } else { 199 mDatabase.disableWriteAheadLogging(); 200 } 201 } 202 mOpenParamsBuilder.setWriteAheadLoggingEnabled(enabled); 203 } 204 205 // Compatibility WAL is disabled if an app disables or enables WAL 206 mOpenParamsBuilder.removeOpenFlags(SQLiteDatabase.ENABLE_LEGACY_COMPATIBILITY_WAL); 207 } 208 } 209 210 /** 211 * Configures <a href="https://sqlite.org/malloc.html#lookaside">lookaside memory allocator</a> 212 * 213 * <p>This method should be called from the constructor of the subclass, 214 * before opening the database, since lookaside memory configuration can only be changed 215 * when no connection is using it 216 * 217 * <p>SQLite default settings will be used, if this method isn't called. 218 * Use {@code setLookasideConfig(0,0)} to disable lookaside 219 * 220 * <p><strong>Note:</strong> Provided slotSize/slotCount configuration is just a recommendation. 221 * The system may choose different values depending on a device, e.g. lookaside allocations 222 * can be disabled on low-RAM devices 223 * 224 * @param slotSize The size in bytes of each lookaside slot. 225 * @param slotCount The total number of lookaside memory slots per database connection. 226 */ setLookasideConfig(@ntRangefrom = 0) final int slotSize, @IntRange(from = 0) final int slotCount)227 public void setLookasideConfig(@IntRange(from = 0) final int slotSize, 228 @IntRange(from = 0) final int slotCount) { 229 synchronized (this) { 230 if (mDatabase != null && mDatabase.isOpen()) { 231 throw new IllegalStateException( 232 "Lookaside memory config cannot be changed after opening the database"); 233 } 234 mOpenParamsBuilder.setLookasideConfig(slotSize, slotCount); 235 } 236 } 237 238 /** 239 * Sets configuration parameters that are used for opening {@link SQLiteDatabase}. 240 * <p>Please note that {@link SQLiteDatabase#CREATE_IF_NECESSARY} flag will always be set when 241 * opening the database 242 * 243 * @param openParams configuration parameters that are used for opening {@link SQLiteDatabase}. 244 * @throws IllegalStateException if the database is already open 245 */ setOpenParams(@onNull SQLiteDatabase.OpenParams openParams)246 public void setOpenParams(@NonNull SQLiteDatabase.OpenParams openParams) { 247 Objects.requireNonNull(openParams); 248 synchronized (this) { 249 if (mDatabase != null && mDatabase.isOpen()) { 250 throw new IllegalStateException( 251 "OpenParams cannot be set after opening the database"); 252 } 253 setOpenParamsBuilder(new SQLiteDatabase.OpenParams.Builder(openParams)); 254 } 255 } 256 setOpenParamsBuilder(SQLiteDatabase.OpenParams.Builder openParamsBuilder)257 private void setOpenParamsBuilder(SQLiteDatabase.OpenParams.Builder openParamsBuilder) { 258 mOpenParamsBuilder = openParamsBuilder; 259 mOpenParamsBuilder.addOpenFlags(SQLiteDatabase.CREATE_IF_NECESSARY); 260 } 261 262 /** 263 * Sets the maximum number of milliseconds that SQLite connection is allowed to be idle 264 * before it is closed and removed from the pool. 265 * 266 * <p>This method should be called from the constructor of the subclass, 267 * before opening the database 268 * 269 * <p><b>DO NOT USE</b> this method. 270 * This feature has negative side effects that are very hard to foresee. 271 * See the javadoc of 272 * {@link SQLiteDatabase.OpenParams.Builder#setIdleConnectionTimeout(long)} 273 * for the details. 274 * 275 * @param idleConnectionTimeoutMs timeout in milliseconds. Use {@link Long#MAX_VALUE} value 276 * to allow unlimited idle connections. 277 * 278 * @see SQLiteDatabase.OpenParams.Builder#setIdleConnectionTimeout(long) 279 * 280 * @deprecated DO NOT USE this method. See the javadoc of 281 * {@link SQLiteDatabase.OpenParams.Builder#setIdleConnectionTimeout(long)} 282 * for the details. 283 */ 284 @Deprecated setIdleConnectionTimeout(@ntRangefrom = 0) final long idleConnectionTimeoutMs)285 public void setIdleConnectionTimeout(@IntRange(from = 0) final long idleConnectionTimeoutMs) { 286 synchronized (this) { 287 if (mDatabase != null && mDatabase.isOpen()) { 288 throw new IllegalStateException( 289 "Connection timeout setting cannot be changed after opening the database"); 290 } 291 mOpenParamsBuilder.setIdleConnectionTimeout(idleConnectionTimeoutMs); 292 } 293 } 294 295 /** 296 * Create and/or open a database that will be used for reading and writing. 297 * The first time this is called, the database will be opened and 298 * {@link #onCreate}, {@link #onUpgrade} and/or {@link #onOpen} will be 299 * called. 300 * 301 * <p>Once opened successfully, the database is cached, so you can 302 * call this method every time you need to write to the database. 303 * (Make sure to call {@link #close} when you no longer need the database.) 304 * Errors such as bad permissions or a full disk may cause this method 305 * to fail, but future attempts may succeed if the problem is fixed.</p> 306 * 307 * <p class="caution">Database upgrade may take a long time, you 308 * should not call this method from the application main thread, including 309 * from {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}. 310 * 311 * @throws SQLiteException if the database cannot be opened for writing 312 * @return a read/write database object valid until {@link #close} is called 313 */ getWritableDatabase()314 public SQLiteDatabase getWritableDatabase() { 315 synchronized (this) { 316 return getDatabaseLocked(true); 317 } 318 } 319 320 /** 321 * Create and/or open a database. This will be the same object returned by 322 * {@link #getWritableDatabase} unless some problem, such as a full disk, 323 * requires the database to be opened read-only. In that case, a read-only 324 * database object will be returned. If the problem is fixed, a future call 325 * to {@link #getWritableDatabase} may succeed, in which case the read-only 326 * database object will be closed and the read/write object will be returned 327 * in the future. 328 * 329 * <p class="caution">Like {@link #getWritableDatabase}, this method may 330 * take a long time to return, so you should not call it from the 331 * application main thread, including from 332 * {@link android.content.ContentProvider#onCreate ContentProvider.onCreate()}. 333 * 334 * @throws SQLiteException if the database cannot be opened 335 * @return a database object valid until {@link #getWritableDatabase} 336 * or {@link #close} is called. 337 */ getReadableDatabase()338 public SQLiteDatabase getReadableDatabase() { 339 synchronized (this) { 340 return getDatabaseLocked(false); 341 } 342 } 343 getDatabaseLocked(boolean writable)344 private SQLiteDatabase getDatabaseLocked(boolean writable) { 345 if (mDatabase != null) { 346 if (!mDatabase.isOpen()) { 347 // Darn! The user closed the database by calling mDatabase.close(). 348 mDatabase = null; 349 } else if (!writable || !mDatabase.isReadOnly()) { 350 // The database is already open for business. 351 return mDatabase; 352 } 353 } 354 355 if (mIsInitializing) { 356 throw new IllegalStateException("getDatabase called recursively"); 357 } 358 359 SQLiteDatabase db = mDatabase; 360 try { 361 mIsInitializing = true; 362 363 if (db != null) { 364 if (writable && db.isReadOnly()) { 365 db.reopenReadWrite(); 366 } 367 } else if (mName == null) { 368 db = SQLiteDatabase.createInMemory(mOpenParamsBuilder.build()); 369 } else { 370 final File filePath = mContext.getDatabasePath(mName); 371 SQLiteDatabase.OpenParams params = mOpenParamsBuilder.build(); 372 try { 373 db = SQLiteDatabase.openDatabase(filePath, params); 374 // Keep pre-O-MR1 behavior by resetting file permissions to 660 375 setFilePermissionsForDb(filePath.getPath()); 376 } catch (SQLException ex) { 377 if (writable) { 378 throw ex; 379 } 380 Log.e(TAG, "Couldn't open database for writing (will try read-only):", ex); 381 params = params.toBuilder().addOpenFlags(SQLiteDatabase.OPEN_READONLY).build(); 382 db = SQLiteDatabase.openDatabase(filePath, params); 383 } 384 } 385 386 onConfigure(db); 387 388 final int version = db.getVersion(); 389 if (version != mNewVersion) { 390 if (db.isReadOnly()) { 391 throw new SQLiteException("Can't upgrade read-only database from version " + 392 db.getVersion() + " to " + mNewVersion + ": " + mName); 393 } 394 395 if (version > 0 && version < mMinimumSupportedVersion) { 396 File databaseFile = new File(db.getPath()); 397 onBeforeDelete(db); 398 db.close(); 399 if (SQLiteDatabase.deleteDatabase(databaseFile)) { 400 mIsInitializing = false; 401 return getDatabaseLocked(writable); 402 } else { 403 throw new IllegalStateException("Unable to delete obsolete database " 404 + mName + " with version " + version); 405 } 406 } else { 407 db.beginTransaction(); 408 try { 409 if (version == 0) { 410 onCreate(db); 411 } else { 412 if (version > mNewVersion) { 413 onDowngrade(db, version, mNewVersion); 414 } else { 415 onUpgrade(db, version, mNewVersion); 416 } 417 } 418 db.setVersion(mNewVersion); 419 db.setTransactionSuccessful(); 420 } finally { 421 db.endTransaction(); 422 } 423 } 424 } 425 426 onOpen(db); 427 mDatabase = db; 428 return db; 429 } finally { 430 mIsInitializing = false; 431 if (db != null && db != mDatabase) { 432 db.close(); 433 } 434 } 435 } 436 setFilePermissionsForDb(String dbPath)437 private static void setFilePermissionsForDb(String dbPath) { 438 int perms = FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IWGRP; 439 FileUtils.setPermissions(dbPath, perms, -1, -1); 440 } 441 442 /** 443 * Close any open database object. 444 */ close()445 public synchronized void close() { 446 if (mIsInitializing) throw new IllegalStateException("Closed during initialization"); 447 448 if (mDatabase != null && mDatabase.isOpen()) { 449 mDatabase.close(); 450 mDatabase = null; 451 } 452 } 453 454 /** 455 * Called when the database connection is being configured, to enable features such as 456 * write-ahead logging or foreign key support. 457 * <p> 458 * This method is called before {@link #onCreate}, {@link #onUpgrade}, {@link #onDowngrade}, or 459 * {@link #onOpen} are called. It should not modify the database except to configure the 460 * database connection as required. 461 * </p> 462 * <p> 463 * This method should only call methods that configure the parameters of the database 464 * connection, such as {@link SQLiteDatabase#enableWriteAheadLogging} 465 * {@link SQLiteDatabase#setForeignKeyConstraintsEnabled}, {@link SQLiteDatabase#setLocale}, 466 * {@link SQLiteDatabase#setMaximumSize}, or executing PRAGMA statements. 467 * </p> 468 * 469 * @param db The database. 470 */ onConfigure(SQLiteDatabase db)471 public void onConfigure(SQLiteDatabase db) {} 472 473 /** 474 * Called before the database is deleted when the version returned by 475 * {@link SQLiteDatabase#getVersion()} is lower than the minimum supported version passed (if at 476 * all) while creating this helper. After the database is deleted, a fresh database with the 477 * given version is created. This will be followed by {@link #onConfigure(SQLiteDatabase)} and 478 * {@link #onCreate(SQLiteDatabase)} being called with a new SQLiteDatabase object 479 * 480 * @param db the database opened with this helper 481 * @see #SQLiteOpenHelper(Context, String, CursorFactory, int, int, DatabaseErrorHandler) 482 * @hide 483 */ onBeforeDelete(SQLiteDatabase db)484 public void onBeforeDelete(SQLiteDatabase db) { 485 } 486 487 /** 488 * Called when the database is created for the first time. This is where the 489 * creation of tables and the initial population of the tables should happen. 490 * 491 * @param db The database. 492 */ onCreate(SQLiteDatabase db)493 public abstract void onCreate(SQLiteDatabase db); 494 495 /** 496 * Called when the database needs to be upgraded. The implementation 497 * should use this method to drop tables, add tables, or do anything else it 498 * needs to upgrade to the new schema version. 499 * 500 * <p> 501 * The SQLite ALTER TABLE documentation can be found 502 * <a href="http://sqlite.org/lang_altertable.html">here</a>. If you add new columns 503 * you can use ALTER TABLE to insert them into a live table. If you rename or remove columns 504 * you can use ALTER TABLE to rename the old table, then create the new table and then 505 * populate the new table with the contents of the old table. 506 * </p><p> 507 * This method executes within a transaction. If an exception is thrown, all changes 508 * will automatically be rolled back. 509 * </p> 510 * <p> 511 * <em>Important:</em> You should NOT modify an existing migration step from version X to X+1 512 * once a build has been released containing that migration step. If a migration step has an 513 * error and it runs on a device, the step will NOT re-run itself in the future if a fix is made 514 * to the migration step.</p> 515 * <p>For example, suppose a migration step renames a database column from {@code foo} to 516 * {@code bar} when the name should have been {@code baz}. If that migration step is released 517 * in a build and runs on a user's device, the column will be renamed to {@code bar}. If the 518 * developer subsequently edits this same migration step to change the name to {@code baz} as 519 * intended, the user devices which have already run this step will still have the name 520 * {@code bar}. Instead, a NEW migration step should be created to correct the error and rename 521 * {@code bar} to {@code baz}, ensuring the error is corrected on devices which have already run 522 * the migration step with the error.</p> 523 * 524 * @param db The database. 525 * @param oldVersion The old database version. 526 * @param newVersion The new database version. 527 */ onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)528 public abstract void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); 529 530 /** 531 * Called when the database needs to be downgraded. This is strictly similar to 532 * {@link #onUpgrade} method, but is called whenever current version is newer than requested one. 533 * However, this method is not abstract, so it is not mandatory for a customer to 534 * implement it. If not overridden, default implementation will reject downgrade and 535 * throws SQLiteException 536 * 537 * <p> 538 * This method executes within a transaction. If an exception is thrown, all changes 539 * will automatically be rolled back. 540 * </p> 541 * 542 * @param db The database. 543 * @param oldVersion The old database version. 544 * @param newVersion The new database version. 545 */ onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion)546 public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { 547 throw new SQLiteException("Can't downgrade database from version " + 548 oldVersion + " to " + newVersion); 549 } 550 551 /** 552 * Called when the database has been opened. The implementation 553 * should check {@link SQLiteDatabase#isReadOnly} before updating the 554 * database. 555 * <p> 556 * This method is called after the database connection has been configured 557 * and after the database schema has been created, upgraded or downgraded as necessary. 558 * If the database connection must be configured in some way before the schema 559 * is created, upgraded, or downgraded, do it in {@link #onConfigure} instead. 560 * </p> 561 * 562 * @param db The database. 563 */ onOpen(SQLiteDatabase db)564 public void onOpen(SQLiteDatabase db) {} 565 } 566