|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.android.H2Database
public class H2Database
This class represents a database connection.
Nested Class Summary | |
---|---|
static interface |
H2Database.CursorFactory
The cursor factory. |
Field Summary | |
---|---|
static int |
CONFLICT_ABORT
When a conflict occurs, abort the current statement, but don't roll back the transaction. |
static int |
CONFLICT_FAIL
When a conflict occurs, return SQLITE_CONSTRAINT, but don't roll back the transaction. |
static int |
CONFLICT_IGNORE
When a conflict occurs, continue, but don't modify the conflicting row. |
static int |
CONFLICT_NONE
When a conflict occurs, do nothing. |
static int |
CONFLICT_REPLACE
When a conflict occurs, the existing rows are replaced. |
static int |
CONFLICT_ROLLBACK
When a conflict occurs, the transaction is rolled back. |
static int |
CREATE_IF_NECESSARY
Create a new database if it doesn't exist. |
static int |
NO_LOCALIZED_COLLATORS
This flag has no effect. |
static int |
OPEN_READONLY
Open the database in read-only mode. |
static int |
OPEN_READWRITE
Open the database in read-write mode (default). |
Method Summary | |
---|---|
void |
beginTransaction()
Start a transaction. |
void |
beginTransactionWithListener(H2TransactionListener transactionListener)
Start a transaction. |
void |
close()
Close the connection. |
H2Statement |
compileStatement(java.lang.String sql)
Prepare a statement. |
static H2Database |
create(H2Database.CursorFactory factory)
Create a new in-memory database. |
int |
delete(java.lang.String table,
java.lang.String whereClause,
java.lang.String[] whereArgs)
Delete a number of rows in this database. |
void |
endTransaction()
End the transaction. |
void |
execSQL(java.lang.String sql)
Execute the given statement. |
void |
execSQL(java.lang.String sql,
java.lang.Object[] bindArgs)
Execute the given statement. |
static java.lang.String |
findEditTable(java.lang.String tables)
TODO |
long |
getMaximumSize()
Get the maximum size of the database file in bytes. |
long |
getPageSize()
Get the page size of the database in bytes. |
java.lang.String |
getPath()
Get the name of the database file. |
java.util.Map<java.lang.String,java.lang.String> |
getSyncedTables()
TODO |
int |
getVersion()
Get the database version. |
long |
insert(java.lang.String table,
java.lang.String nullColumnHack,
android.content.ContentValues values)
Insert a row. |
long |
insertOrThrow(java.lang.String table,
java.lang.String nullColumnHack,
android.content.ContentValues values)
Try to insert a row. |
long |
insertWithOnConflict(java.lang.String table,
java.lang.String nullColumnHack,
android.content.ContentValues initialValues,
int conflictAlgorithm)
Try to insert a row, using the given conflict resolution option. |
boolean |
inTransaction()
Check if there is an open transaction. |
boolean |
isDbLockedByCurrentThread()
Check if the database is locked by the current thread. |
boolean |
isDbLockedByOtherThreads()
Check if the database is locked by a different thread. |
boolean |
isOpen()
Check if the connection is open. |
boolean |
isReadOnly()
Check if the connection is read-only. |
void |
markTableSyncable(java.lang.String table,
java.lang.String deletedTable)
TODO |
void |
markTableSyncable(java.lang.String table,
java.lang.String foreignKey,
java.lang.String updateTable)
TODO |
boolean |
needUpgrade(int newVersion)
Check if an upgrade is required. |
static H2Database |
openDatabase(java.lang.String path,
H2Database.CursorFactory factory,
int flags)
Open a connection to the given database. |
static H2Database |
openOrCreateDatabase(java.io.File file,
H2Database.CursorFactory factory)
Open a connection to the given database. |
static H2Database |
openOrCreateDatabase(java.lang.String path,
H2Database.CursorFactory factory)
Open a connection to the given database. |
android.database.Cursor |
query(boolean distinct,
java.lang.String table,
java.lang.String[] columns,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String groupBy,
java.lang.String having,
java.lang.String orderBy,
java.lang.String limit)
Execute the SELECT statement for the given parameters. |
android.database.Cursor |
query(java.lang.String table,
java.lang.String[] columns,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String groupBy,
java.lang.String having,
java.lang.String orderBy)
Execute the SELECT statement for the given parameters. |
android.database.Cursor |
query(java.lang.String table,
java.lang.String[] columns,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String groupBy,
java.lang.String having,
java.lang.String orderBy,
java.lang.String limit)
Execute the SELECT statement for the given parameters. |
android.database.Cursor |
queryWithFactory(H2Database.CursorFactory cursorFactory,
boolean distinct,
java.lang.String table,
java.lang.String[] columns,
java.lang.String selection,
java.lang.String[] selectionArgs,
java.lang.String groupBy,
java.lang.String having,
java.lang.String orderBy,
java.lang.String limit)
Execute the SELECT statement for the given parameters. |
android.database.Cursor |
rawQuery(java.lang.String sql,
java.lang.String[] selectionArgs)
Execute the query. |
android.database.Cursor |
rawQueryWithFactory(H2Database.CursorFactory cursorFactory,
java.lang.String sql,
java.lang.String[] selectionArgs,
java.lang.String editTable)
Execute the query using the given cursor factory. |
static int |
releaseMemory()
Try to release memory. |
long |
replace(java.lang.String table,
java.lang.String nullColumnHack,
android.content.ContentValues initialValues)
Replace an existing row in the database. |
long |
replaceOrThrow(java.lang.String table,
java.lang.String nullColumnHack,
android.content.ContentValues initialValues)
Try to replace an existing row in the database. |
void |
setLocale(java.util.Locale locale)
Set the locale. |
void |
setLockingEnabled(boolean lockingEnabled)
Enable or disable thread safety. |
long |
setMaximumSize(long numBytes)
Set the maximum database file size. |
void |
setPageSize(long numBytes)
Set the database page size. |
void |
setTransactionSuccessful()
Mark the transaction as completed successfully. |
void |
setVersion(int version)
Update the database version. |
static java.lang.RuntimeException |
unsupported()
Create a new RuntimeException that says this feature is not supported. |
int |
update(java.lang.String table,
android.content.ContentValues values,
java.lang.String whereClause,
java.lang.String[] whereArgs)
Update one or multiple rows. |
int |
updateWithOnConflict(java.lang.String table,
android.content.ContentValues values,
java.lang.String whereClause,
java.lang.String[] whereArgs,
int conflictAlgorithm)
Update one or multiple rows. |
boolean |
yieldIfContended()
Deprecated. |
boolean |
yieldIfContendedSafely()
Temporarily pause the transaction. |
boolean |
yieldIfContendedSafely(long sleepAfterYieldDelay)
Temporarily pause the transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CONFLICT_ABORT
public static final int CONFLICT_FAIL
public static final int CONFLICT_IGNORE
public static final int CONFLICT_NONE
public static final int CONFLICT_REPLACE
public static final int CONFLICT_ROLLBACK
public static final int CREATE_IF_NECESSARY
public static final int NO_LOCALIZED_COLLATORS
public static final int OPEN_READONLY
public static final int OPEN_READWRITE
Method Detail |
---|
public static H2Database create(H2Database.CursorFactory factory)
factory
- the cursor factory
public static H2Database openDatabase(java.lang.String path, H2Database.CursorFactory factory, int flags)
path
- the database file namefactory
- the cursor factoryflags
- 0, or a combination of OPEN_READONLY and CREATE_IF_NECESSARY
public static H2Database openOrCreateDatabase(java.io.File file, H2Database.CursorFactory factory)
file
- the database filefactory
- the cursor factory
public static H2Database openOrCreateDatabase(java.lang.String path, H2Database.CursorFactory factory)
path
- the database file namefactory
- the cursor factory
public void beginTransaction()
public void beginTransactionWithListener(H2TransactionListener transactionListener)
transactionListener
- the transaction listener to usepublic void close()
public H2Statement compileStatement(java.lang.String sql)
sql
- the statement
public int delete(java.lang.String table, java.lang.String whereClause, java.lang.String[] whereArgs)
table
- the tablewhereClause
- the conditionwhereArgs
- the parameter values
public void endTransaction()
public void execSQL(java.lang.String sql, java.lang.Object[] bindArgs)
sql
- the statementbindArgs
- the parameter valuespublic void execSQL(java.lang.String sql)
sql
- the statementpublic static java.lang.String findEditTable(java.lang.String tables)
tables
- the list of tables
public long getMaximumSize()
public long getPageSize()
public java.lang.String getPath()
public java.util.Map<java.lang.String,java.lang.String> getSyncedTables()
public int getVersion()
public boolean inTransaction()
public long insert(java.lang.String table, java.lang.String nullColumnHack, android.content.ContentValues values)
table
- the tablenullColumnHack
- not usedvalues
- the values
public long insertOrThrow(java.lang.String table, java.lang.String nullColumnHack, android.content.ContentValues values)
table
- the tablenullColumnHack
- not usedvalues
- the values
public long insertWithOnConflict(java.lang.String table, java.lang.String nullColumnHack, android.content.ContentValues initialValues, int conflictAlgorithm)
table
- the tablenullColumnHack
- not usedinitialValues
- the valuesconflictAlgorithm
- what conflict resolution to use
public boolean isDbLockedByCurrentThread()
public boolean isDbLockedByOtherThreads()
public boolean isOpen()
public boolean isReadOnly()
public void markTableSyncable(java.lang.String table, java.lang.String deletedTable)
table
- the tabledeletedTable
- TODOpublic void markTableSyncable(java.lang.String table, java.lang.String foreignKey, java.lang.String updateTable)
table
- the tableforeignKey
- the foreign keyupdateTable
- TODOpublic boolean needUpgrade(int newVersion)
newVersion
- the new version
public android.database.Cursor query(boolean distinct, java.lang.String table, java.lang.String[] columns, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String groupBy, java.lang.String having, java.lang.String orderBy, java.lang.String limit)
distinct
- if only distinct rows should be returnedtable
- the tablecolumns
- the list of columnsselection
- TODOselectionArgs
- TODOgroupBy
- the group by list or nullhaving
- the having condition or nullorderBy
- the order by list or nulllimit
- the limit or null
public android.database.Cursor query(java.lang.String table, java.lang.String[] columns, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String groupBy, java.lang.String having, java.lang.String orderBy)
table
- the tablecolumns
- the list of columnsselection
- TODOselectionArgs
- TODOgroupBy
- the group by list or nullhaving
- the having condition or nullorderBy
- the order by list or null
public android.database.Cursor query(java.lang.String table, java.lang.String[] columns, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String groupBy, java.lang.String having, java.lang.String orderBy, java.lang.String limit)
table
- the tablecolumns
- the list of columnsselection
- TODOselectionArgs
- TODOgroupBy
- the group by list or nullhaving
- the having condition or nullorderBy
- the order by list or nulllimit
- the limit or null
public android.database.Cursor queryWithFactory(H2Database.CursorFactory cursorFactory, boolean distinct, java.lang.String table, java.lang.String[] columns, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String groupBy, java.lang.String having, java.lang.String orderBy, java.lang.String limit)
cursorFactory
- the cursor factory to usedistinct
- if only distinct rows should be returnedtable
- the tablecolumns
- the list of columnsselection
- TODOselectionArgs
- TODOgroupBy
- the group by list or nullhaving
- the having condition or nullorderBy
- the order by list or nulllimit
- the limit or null
public android.database.Cursor rawQuery(java.lang.String sql, java.lang.String[] selectionArgs)
sql
- the SQL statementselectionArgs
- the parameter values
public android.database.Cursor rawQueryWithFactory(H2Database.CursorFactory cursorFactory, java.lang.String sql, java.lang.String[] selectionArgs, java.lang.String editTable)
cursorFactory
- the cursor factorysql
- the SQL statementselectionArgs
- the parameter valueseditTable
- TODO
public static int releaseMemory()
public long replace(java.lang.String table, java.lang.String nullColumnHack, android.content.ContentValues initialValues)
table
- the tablenullColumnHack
- ignoredinitialValues
- the values
public long replaceOrThrow(java.lang.String table, java.lang.String nullColumnHack, android.content.ContentValues initialValues)
table
- the tablenullColumnHack
- ignoredinitialValues
- the values
public void setLocale(java.util.Locale locale)
locale
- the new localepublic void setLockingEnabled(boolean lockingEnabled)
lockingEnabled
- the new valuepublic long setMaximumSize(long numBytes)
numBytes
- the file size in bytes
public void setPageSize(long numBytes)
numBytes
- the page sizepublic void setTransactionSuccessful()
public void setVersion(int version)
version
- the versionpublic int update(java.lang.String table, android.content.ContentValues values, java.lang.String whereClause, java.lang.String[] whereArgs)
table
- the tablevalues
- the valueswhereClause
- the where conditionwhereArgs
- the parameter values
public int updateWithOnConflict(java.lang.String table, android.content.ContentValues values, java.lang.String whereClause, java.lang.String[] whereArgs, int conflictAlgorithm)
table
- the tablevalues
- the valueswhereClause
- the where conditionwhereArgs
- the parameter valuesconflictAlgorithm
- the conflict resolution option
public boolean yieldIfContended()
public boolean yieldIfContendedSafely(long sleepAfterYieldDelay)
sleepAfterYieldDelay
- TODO
public boolean yieldIfContendedSafely()
public static java.lang.RuntimeException unsupported()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |