Share via


SQLiteOpenHelper Class

Definition

A helper class to manage database creation and version management.

[Android.Runtime.Register("android/database/sqlite/SQLiteOpenHelper", DoNotGenerateAcw=true)]
public abstract class SQLiteOpenHelper : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.Lang.IAutoCloseable
[<Android.Runtime.Register("android/database/sqlite/SQLiteOpenHelper", DoNotGenerateAcw=true)>]
type SQLiteOpenHelper = class
    inherit Object
    interface IAutoCloseable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
SQLiteOpenHelper
Attributes
Implements

Remarks

A helper class to manage database creation and version management.

You create a subclass implementing #onCreate, #onUpgrade and optionally #onOpen, and this class takes care of opening the database if it exists, creating it if it does not, and upgrading it as necessary. Transactions are used to make sure the database is always in a sensible state.

This class makes it easy for android.content.ContentProvider implementations to defer opening and upgrading the database until first use, to avoid blocking application startup with long-running database upgrades.

For an example, see the NotePadProvider class in the NotePad sample application, in the <em>samples/</em> directory of the SDK.

<p class="note"><strong>Note:</strong> this class assumes monotonically increasing version numbers for upgrades.</p>

<p class="note"><strong>Note:</strong> the AutoCloseable interface was first added in the android.os.Build.VERSION_CODES#Q release.</p>

Java documentation for android.database.sqlite.SQLiteOpenHelper.

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.

Constructors

SQLiteOpenHelper(Context, String, Int32, SQLiteDatabase+OpenParams)

Create a helper object to create, open, and/or manage a database.

SQLiteOpenHelper(Context, String, SQLiteDatabase+ICursorFactory, Int32, IDatabaseErrorHandler)

Create a helper object to create, open, and/or manage a database.

SQLiteOpenHelper(Context, String, SQLiteDatabase+ICursorFactory, Int32)

Create a helper object to create, open, and/or manage a database.

SQLiteOpenHelper(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
DatabaseName

Return the name of the SQLite database being opened, as given to the constructor.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ReadableDatabase

Create and/or open a database.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

WritableDatabase

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

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Close()

Close any open database object.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
OnConfigure(SQLiteDatabase)

Called when the database connection is being configured, to enable features such as write-ahead logging or foreign key support.

OnCreate(SQLiteDatabase)

Called when the database is created for the first time.

OnDowngrade(SQLiteDatabase, Int32, Int32)

Called when the database needs to be downgraded.

OnOpen(SQLiteDatabase)

Called when the database has been opened.

OnUpgrade(SQLiteDatabase, Int32, Int32)

Called when the database needs to be upgraded.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetIdleConnectionTimeout(Int64)

Sets the maximum number of milliseconds that SQLite connection is allowed to be idle before it is closed and removed from the pool.

SetLookasideConfig(Int32, Int32)

Configures lookaside memory allocator

SetOpenParams(SQLiteDatabase+OpenParams)

Sets configuration parameters that are used for opening SQLiteDatabase.

SetWriteAheadLoggingEnabled(Boolean)

Enables or disables the use of write-ahead logging for the database.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to