org.cyberlab.db.local
Class AbstractSQLiteDBAdapter<T>

java.lang.Object
  extended by org.cyberlab.db.local.AbstractSQLiteDBAdapter<T>
Type Parameters:
T - The class type of the new SQliteDBAdapter.
Direct Known Subclasses:
QuizSQLiteDBAdapter

public abstract class AbstractSQLiteDBAdapter<T>
extends java.lang.Object

Applications using SQLite databases extend this class. This helps create the application SQLite database from files containing legal SQLite statements or by copying an existing database into the application. This class uses the DatabaseHelper.

Author:
matsgora

Field Summary
protected  java.lang.String DATABASE_NAME
           
protected  Context mCtx
           
protected  SQLiteDatabase mDb
           
protected  DatabaseHelper mDbHelper
           
 
Constructor Summary
AbstractSQLiteDBAdapter(Context ctx, java.lang.String dbFile)
           
AbstractSQLiteDBAdapter(Context ctx, java.lang.String dbFile, java.io.InputStream inputstream)
          Installs a pre-existing SQLite database into application.
AbstractSQLiteDBAdapter(Context ctx, java.lang.String dbFile, java.net.URL dbLocation)
          Installs a pre-existing SQLite database into application.
 
Method Summary
 void close()
          Closes the database
 void exportDatabase(java.io.File out)
          Export database to external file
 boolean isOpen()
          Checks if database is opened
 T open()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_NAME

protected final java.lang.String DATABASE_NAME

mCtx

protected Context mCtx

mDbHelper

protected DatabaseHelper mDbHelper

mDb

protected SQLiteDatabase mDb
Constructor Detail

AbstractSQLiteDBAdapter

public AbstractSQLiteDBAdapter(Context ctx,
                               java.lang.String dbFile)
Parameters:
ctx - Application context
dbFile - A file with this name must exist in the assets folder. This file contains legal SQLite syntax for creating a database

AbstractSQLiteDBAdapter

public AbstractSQLiteDBAdapter(Context ctx,
                               java.lang.String dbFile,
                               java.net.URL dbLocation)
                        throws java.lang.Exception
Installs a pre-existing SQLite database into application. Caution: Database must be compatible with database adapter.

Parameters:
ctx - Application context
dbFile - Name of database (name of SQLite database file located in applications data directory)
dbLocation - URL location of pre-existing database
Throws:
java.io.IOException
java.lang.Exception

AbstractSQLiteDBAdapter

public AbstractSQLiteDBAdapter(Context ctx,
                               java.lang.String dbFile,
                               java.io.InputStream inputstream)
                        throws java.lang.Exception
Installs a pre-existing SQLite database into application. Caution: Database must be compatible with database adapter.

Parameters:
ctx - Application Context
dbFile - Name of database (name of SQLite database file located in applications data directory)
dbLocation - InputStream of pre-existing database
Throws:
java.io.IOException
java.lang.Exception
Method Detail

open

public T open()
       throws SQLException
Throws:
SQLException

close

public void close()
Closes the database


isOpen

public boolean isOpen()
Checks if database is opened

Returns:
true if database is open

exportDatabase

public void exportDatabase(java.io.File out)
                    throws java.lang.Exception
Export database to external file

Parameters:
out -
Throws:
java.lang.Exception