Share via

SQLiteOpenHelper.WritableDatabase Property


Create and/or open a database that will be used for reading and writing.

public virtual Android.Database.Sqlite.SQLiteDatabase? WritableDatabase { [Android.Runtime.Register("getWritableDatabase", "()Landroid/database/sqlite/SQLiteDatabase;", "GetGetWritableDatabaseHandler")] get; }
[<get: Android.Runtime.Register("getWritableDatabase", "()Landroid/database/sqlite/SQLiteDatabase;", "GetGetWritableDatabaseHandler")>]
member this.WritableDatabase : Android.Database.Sqlite.SQLiteDatabase

Property Value

a read/write database object valid until #close is called



if the database cannot be opened for writing


Create and/or open a database that will be used for reading and writing. The first time this is called, the database will be opened and #onCreate, #onUpgrade and/or #onOpen will be called.

Once opened successfully, the database is cached, so you can call this method every time you need to write to the database. (Make sure to call #close when you no longer need the database.) Errors such as bad permissions or a full disk may cause this method to fail, but future attempts may succeed if the problem is fixed.

<p class="caution">Database upgrade may take a long time, you should not call this method from the application main thread, including from android.content.ContentProvider#onCreate ContentProvider.onCreate().

Java documentation for android.database.sqlite.SQLiteOpenHelper.getWritableDatabase().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to