|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.quickconnect.dbaccess.DataAccessObject
public class DataAccessObject
The DataAccessObject class is a wrapper created to ease the use of SQLite databases available in Android Applications.
It supports the use of multiple databases per application, database transactions, and all transactions, queries, insertions
into the database, and modifications of existing data are thread safe.
To use this wrapper include an SQLite file in the assets directory of your Android application. To access this database call
the DataAccessObject getData static method. To make database modifications use the DataAccesObject setData method. Both of these
methods will do all of the preparatory setup required to use the database if it has not already been done.
Transactions are started and stopped using the DataAccessObject startTransaction and endTransaction methods. If the endTransaction
method is passed false as the third parameter then a roll back of the changes done as part of the transaction will be executed.
If your database is not going to be used any longer you can use the DataAccessObject close method to free the resources. Only close
databases if you will no longer be using them during the run of your application or you need to free resources for memory reasons.
Method Summary | |
---|---|
static void |
close(Activity anActivity,
java.lang.String databaseName)
This method is used to free up resources required to access a specific SQLite database file. |
static void |
closeAll()
This method is used to free up resources required to access all open SQLite database files. |
static void |
endTransaction(Activity anActivity,
java.lang.String databaseName,
boolean successful)
This method is used as the ending boundary of a database transaction. |
static DataAccessResult |
getData(Activity anActivity,
java.lang.String databaseName,
java.lang.String SQL,
java.lang.Object[] parameters)
This method is used to execute standard SQL query statements and matching prepared statements against any SQLite database file included in the assets directory of an Android application. |
static DataAccessResult |
setData(Activity anActivity,
java.lang.String databaseName,
java.lang.String SQL,
java.lang.Object[] parameters)
This method is used to execute standard insert, update, etc. |
static void |
startTransaction(Activity anActivity,
java.lang.String databaseName)
This method is used as the beginning boundary of a database transaction. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static DataAccessResult getData(Activity anActivity, java.lang.String databaseName, java.lang.String SQL, java.lang.Object[] parameters) throws org.quickconnect.dbaccess.DataAccessException
anActivity
- - The Activity object with which the database is associated. This is usually the main, or first, Activity of
the application.databaseName
- - A string that matches the name of the SQLite file included in the assets directory of the Android application.SQL
- - An SQL string for a standard SQL statement or a prepared statement used to query the databaseparameters
- - An array of Objects to be bound to the ? characters in the SQL string if it is a prepared statement. If the
SQL string is not to be used for a prepared statement this parameter should be null.
org.quickconnect.dbaccess.DataAccessException
public static DataAccessResult setData(Activity anActivity, java.lang.String databaseName, java.lang.String SQL, java.lang.Object[] parameters) throws org.quickconnect.dbaccess.DataAccessException
anActivity
- - The Activity object with which the database is associated. This is usually the main, or first, Activity of
the application.databaseName
- - A string that matches the name of the SQLite file included in the assets directory of the Android application.SQL
- - An SQL string for a standard SQL statement or a prepared statement used to query the databaseparameters
- - An array of Objects to be bound to the ? characters in the SQL string if it is a prepared statement. If the
SQL string is not to be used for a prepared statement this parameter should be null.
org.quickconnect.dbaccess.DataAccessException
public static void startTransaction(Activity anActivity, java.lang.String databaseName) throws org.quickconnect.dbaccess.DataAccessException
anActivity
- - The Activity object with which the database is associated. This is usually the main, or first, Activity of
the application.databaseName
- - A string that matches the name of the SQLite file included in the assets directory of the Android application.
org.quickconnect.dbaccess.DataAccessException
public static void endTransaction(Activity anActivity, java.lang.String databaseName, boolean successful) throws org.quickconnect.dbaccess.DataAccessException
anActivity
- - The Activity object with which the database is associated. This is usually the main, or first, Activity of
the application.databaseName
- - A string that matches the name of the SQLite file included in the assets directory of the Android application.successful
- - a boolean value indicating if a roll back of all statements in the transaction should be done. A value of
true causes a roll back, false does not.
org.quickconnect.dbaccess.DataAccessException
public static void close(Activity anActivity, java.lang.String databaseName) throws org.quickconnect.dbaccess.DataAccessException
anActivity
- - The Activity object with which the database is associated. This is usually the main, or first, Activity of
the application.databaseName
- - A string that matches the name of the SQLite file included in the assets directory of the Android application.
org.quickconnect.dbaccess.DataAccessException
public static void closeAll()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |