Udostępnij za pośrednictwem


SQLiteDatabase Class

Definition

Exposes methods to manage a SQLite database.

[Android.Runtime.Register("android/database/sqlite/SQLiteDatabase", DoNotGenerateAcw=true)]
public class SQLiteDatabase : Android.Database.Sqlite.SQLiteClosable
[<Android.Runtime.Register("android/database/sqlite/SQLiteDatabase", DoNotGenerateAcw=true)>]
type SQLiteDatabase = class
    inherit SQLiteClosable
Inheritance
SQLiteDatabase
Attributes

Remarks

Exposes methods to manage a SQLite database.

SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks.

See the Notepad sample application in the SDK for an example of creating and managing a database.

Database names must be unique within an application, not across all applications.

<h3>Localized Collation - ORDER BY</h3>

In addition to SQLite's default BINARY collator, Android supplies two more, LOCALIZED, which changes with the system's current locale, and UNICODE, which is the Unicode Collation Algorithm and not tailored to the current locale.

Java documentation for android.database.sqlite.SQLiteDatabase.

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

SQLiteDatabase(IntPtr, JniHandleOwnership)

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

Fields

ConflictAbort
Obsolete.

When a constraint violation occurs,no ROLLBACK is executed so changes from prior commands within the same transaction are preserved.

ConflictFail
Obsolete.

When a constraint violation occurs, the command aborts with a return code SQLITE_CONSTRAINT.

ConflictIgnore
Obsolete.

When a constraint violation occurs, the one row that contains the constraint violation is not inserted or changed.

ConflictNone
Obsolete.

Use the following when no conflict action is specified.

ConflictReplace
Obsolete.

When a UNIQUE constraint violation occurs, the pre-existing rows that are causing the constraint violation are removed prior to inserting or updating the current row.

ConflictRollback
Obsolete.

When a constraint violation occurs, an immediate ROLLBACK occurs, thus ending the current transaction, and the command aborts with a return code of SQLITE_CONSTRAINT.

JournalModeDelete

The DELETE journaling mode is the normal behavior.

JournalModeMemory

The MEMORY journaling mode stores the rollback journal in volatile RAM.

JournalModeOff

The OFF journaling mode disables the rollback journal completely.

JournalModePersist

The PERSIST journaling mode prevents the rollback journal from being deleted at the end of each transaction.

JournalModeTruncate

The TRUNCATE journaling mode commits transactions by truncating the rollback journal to zero-length instead of deleting it.

JournalModeWal

The WAL journaling mode uses a write-ahead log instead of a rollback journal to implement transactions.

MaxSqlCacheSize

Absolute max value that can be set by #setMaxSqlCacheSize(int).

SqliteMaxLikePatternLength

Maximum Length Of A LIKE Or GLOB Pattern The pattern matching algorithm used in the default LIKE and GLOB implementation of SQLite can exhibit O(N^2) performance (where N is the number of characters in the pattern) for certain pathological cases.

SyncModeExtra

The EXTRA sync mode is like FULL sync mode with the addition that the directory containing a rollback journal is synced after that journal is unlinked to commit a transaction in DELETE journal mode.

SyncModeFull

In FULL sync mode the SQLite database engine will use the xSync method of the VFS to ensure that all content is safely written to the disk surface prior to continuing.

SyncModeNormal

The NORMAL sync mode, the SQLite database engine will still sync at the most critical moments, but less often than in FULL mode.

SyncModeOff

In OFF sync mode SQLite continues without syncing as soon as it has handed data off to the operating system.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsDatabaseIntegrityOk

Runs 'pragma integrity_check' on the given database (and all the attached databases) and returns true if the given database (and all its attached databases) pass integrity_check, false otherwise.

IsDbLockedByCurrentThread

Returns true if the current thread is holding an active connection to the database.

IsDbLockedByOtherThreads
Obsolete.

Always returns false.

IsOpen

Returns true if the database is currently open.

IsReadOnly

Returns true if the database is opened as read only.

IsWriteAheadLoggingEnabled

Returns true if write-ahead logging has been enabled for this database.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MaximumSize

Returns the maximum size the database may grow to.

PageSize

Returns the current database page size, in bytes. -or- Sets the database page size.

Path

Gets the path to the database file.

PeerReference (Inherited from Object)
SyncedTables
Obsolete.

Deprecated.

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.

Version

Gets the database version. -or- Sets the database version.

Methods

AcquireReference()

Acquires a reference to the object.

(Inherited from SQLiteClosable)
BeginTransaction()

Begins a transaction in EXCLUSIVE mode.

BeginTransactionNonExclusive()

Begins a transaction in IMMEDIATE mode.

BeginTransactionWithListener(ISQLiteTransactionListener)

Begins a transaction in EXCLUSIVE mode.

BeginTransactionWithListenerNonExclusive(ISQLiteTransactionListener)

Begins a transaction in IMMEDIATE mode.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Close()
CompileStatement(String)

Compiles an SQL statement into a reusable pre-compiled statement object.

Create(SQLiteDatabase+ICursorFactory)

Create a memory backed SQLite database.

CreateInMemory(SQLiteDatabase+OpenParams)

Create a memory backed SQLite database.

Delete(String, String, String[])

Convenience method for deleting rows in the database.

DeleteDatabase(File)

Deletes a database including its journal file and other auxiliary files that may have been created by the database engine.

DisableWriteAheadLogging()

This method disables the features enabled by #enableWriteAheadLogging().

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
EnableWriteAheadLogging()

This method enables parallel execution of queries from multiple threads on the same database.

EndTransaction()

End a transaction.

Equals(Object)

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

(Inherited from Object)
ExecPerConnectionSQL(String, Object[])

Execute the given SQL statement on all connections to this database.

ExecSQL(String, Object[])

Execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.

ExecSQL(String)

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

FindEditTable(String)

Finds the name of the first table, which is editable.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Insert(String, String, ContentValues)

Convenience method for inserting a row into the database.

InsertOrThrow(String, String, ContentValues)

Convenience method for inserting a row into the database.

InsertWithOnConflict(String, String, ContentValues, Conflict)

General method for inserting a row into the database.

InTransaction()

Returns true if the current thread has a transaction pending.

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)
MarkTableSyncable(String, String, String)
Obsolete.

Mark this table as syncable, with the _sync_dirty residing in another table.

MarkTableSyncable(String, String)
Obsolete.

Mark this table as syncable.

NeedUpgrade(Int32)

Returns true if the new version code is greater than the current database version.

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)
OnAllReferencesReleased()

Called when the last reference to the object was released by a call to ReleaseReference() or Close().

OnAllReferencesReleasedFromContainer()
Obsolete.

Called when the last reference to the object was released by a call to #releaseReferenceFromContainer().

(Inherited from SQLiteClosable)
OpenDatabase(File, SQLiteDatabase+OpenParams)

Open the database according to the specified OpenParams parameters

OpenDatabase(String, SQLiteDatabase+ICursorFactory, DatabaseOpenFlags, IDatabaseErrorHandler)

Open the database according to the specified OpenParams parameters

OpenDatabase(String, SQLiteDatabase+ICursorFactory, DatabaseOpenFlags)

Open the database according to the specified OpenParams parameters

OpenOrCreateDatabase(File, SQLiteDatabase+ICursorFactory)

Equivalent to openDatabase(file.

OpenOrCreateDatabase(String, SQLiteDatabase+ICursorFactory, IDatabaseErrorHandler)

Equivalent to openDatabase(file.

OpenOrCreateDatabase(String, SQLiteDatabase+ICursorFactory)

Equivalent to openDatabase(file.

Query(Boolean, String, String[], String, String[], String, String, String, String, CancellationSignal)

Query the given URL, returning a Cursor over the result set.

Query(Boolean, String, String[], String, String[], String, String, String, String)

Query the given URL, returning a Cursor over the result set.

Query(String, String[], String, String[], String, String, String, String)

Query the given table, returning a Cursor over the result set.

Query(String, String[], String, String[], String, String, String)

Query the given table, returning a Cursor over the result set.

QueryWithFactory(SQLiteDatabase+ICursorFactory, Boolean, String, String[], String, String[], String, String, String, String, CancellationSignal)

Query the given URL, returning a Cursor over the result set.

QueryWithFactory(SQLiteDatabase+ICursorFactory, Boolean, String, String[], String, String[], String, String, String, String)

Query the given URL, returning a Cursor over the result set.

RawQuery(String, String[], CancellationSignal)

Runs the provided SQL and returns a Cursor over the result set.

RawQuery(String, String[])

Runs the provided SQL and returns a Cursor over the result set.

RawQueryWithFactory(SQLiteDatabase+ICursorFactory, String, String[], String, CancellationSignal)

Runs the provided SQL and returns a cursor over the result set.

RawQueryWithFactory(SQLiteDatabase+ICursorFactory, String, String[], String)

Runs the provided SQL and returns a cursor over the result set.

ReleaseMemory()

Attempts to release memory that SQLite holds but does not require to operate properly.

ReleaseReference()

Releases a reference to the object, closing the object if the last reference was released.

(Inherited from SQLiteClosable)
ReleaseReferenceFromContainer()
Obsolete.

Releases a reference to the object that was owned by the container of the object, closing the object if the last reference was released.

(Inherited from SQLiteClosable)
Replace(String, String, ContentValues)

Convenience method for replacing a row in the database.

ReplaceOrThrow(String, String, ContentValues)

Convenience method for replacing a row in the database.

SetCustomAggregateFunction(String, IBinaryOperator)

Register a custom aggregate function that can be called from SQL expressions.

SetCustomScalarFunction(String, IUnaryOperator)

Register a custom scalar function that can be called from SQL expressions.

SetForeignKeyConstraintsEnabled(Boolean)

Sets whether foreign key constraints are enabled for the database.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLocale(Locale)

Sets the locale for this database.

SetLockingEnabled(Boolean)
Obsolete.

Control whether or not the SQLiteDatabase is made thread-safe by using locks around critical sections.

SetMaximumSize(Int64)

Sets the maximum size the database will grow to.

SetMaxSqlCacheSize(Int32)

Sets the maximum size of the prepared-statement cache for this database.

SetTransactionSuccessful()

Marks the current transaction as successful.

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

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Update(String, ContentValues, String, String[])

Convenience method for updating rows in the database.

UpdateWithOnConflict(String, ContentValues, String, String[], Conflict)

Convenience method for updating rows in the database.

ValidateSql(String, CancellationSignal)

Verifies that a SQL SELECT statement is valid by compiling it.

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)
YieldIfContended()
Obsolete.

Temporarily end the transaction to let other threads run.

YieldIfContendedSafely()

Temporarily end the transaction to let other threads run.

YieldIfContendedSafely(Int64)

Temporarily end the transaction to let other threads run.

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