public abstract class Database extends Object
Storage
which is more portable.Constructor and Description |
---|
Database() |
Modifier and Type | Method and Description |
---|---|
abstract void |
beginTransaction()
Starts a transaction
|
abstract void |
close()
Closes the database
|
abstract void |
commitTransaction()
Commits current transaction
|
static void |
delete(String databaseName)
Deletes database
|
abstract void |
execute(String sql)
Execute an update query.
|
void |
execute(String sql,
Object[] params)
Execute an update query with params.
|
abstract void |
execute(String sql,
String[] params)
Execute an update query with params.
|
abstract Cursor |
executeQuery(String sql)
This method should be called with SELECT type statements that return
row set.
|
abstract Cursor |
executeQuery(String sql,
String[] params)
This method should be called with SELECT type statements that return
row set.
|
static boolean |
exists(String databaseName)
Indicates weather a database exists
|
static String |
getDatabasePath(String databaseName)
Returns the file path of the Database if exists and if supported on
the platform.
|
static Database |
openOrCreate(String databaseName)
Opens a database or create one if not exists
|
abstract void |
rollbackTransaction()
Rolls back current transaction
|
public static Database openOrCreate(String databaseName) throws IOException
databaseName
- the name of the databaseIOException
- if database cannot be createdpublic static boolean exists(String databaseName)
databaseName
- the name of the databasepublic static void delete(String databaseName) throws IOException
databaseName
- the name of the databaseIOException
- if database cannot be deletedpublic static String getDatabasePath(String databaseName)
public abstract void beginTransaction() throws IOException
IOException
- if database is not openedpublic abstract void commitTransaction() throws IOException
IOException
- if database is not opened or transaction was not startedpublic abstract void rollbackTransaction() throws IOException
IOException
- if database is not opened or transaction was not startedpublic abstract void close() throws IOException
IOException
public abstract void execute(String sql) throws IOException
sql
- the sql to executeIOException
public abstract void execute(String sql, String[] params) throws IOException
sql
- the sql to executeparams
- to bind to the query where the '?' existsIOException
public void execute(String sql, Object[] params) throws IOException
sql
- the sql to executeparams
- to bind to the query where the '?' exists, supported object
types are String, byte[], Double, Long and nullIOException
public abstract Cursor executeQuery(String sql, String[] params) throws IOException
sql
- the sql to executeparams
- to bind to the query where the '?' existsIOException
public abstract Cursor executeQuery(String sql) throws IOException
sql
- the sql to executeIOException