org.cyberlab.local.db
Class DatabaseHelper

java.lang.Object
  extended by SQLiteOpenHelper
      extended by org.cyberlab.local.db.DatabaseHelper

public class DatabaseHelper
extends SQLiteOpenHelper

Simple SQLite database access helper class. Helps create and manage the SQLite database. Creation is done by either using a file containing legal SQLite statements or by loading an existing database into the application. This class should only be implemented by abstract SQLiteDBAdapters. Concrete application database adapters should extend the abstract SQLiteDBAdapters i.e. AbstractSQLiteDBAdapter. The database helper is used by AbstractSQLiteDBAdapter

Author:
Mats-Gøran Karlsen

Field Summary
static java.lang.String TAG
           
 
Constructor Summary
DatabaseHelper(Context context, java.lang.String dbFile, CursorFactory factory, int dbVersion)
           
 
Method Summary
 void exportDatabase(java.io.File out)
          Exports the database to file
 void loadDatabase(java.io.InputStream inputstream)
          Caution: Overwrites existing application database.
 void loadDatabase(java.net.URL location)
          Caution: Overwrites existing application database.
 void onCreate(SQLiteDatabase arg0)
           
 void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

public static final java.lang.String TAG
See Also:
Constant Field Values
Constructor Detail

DatabaseHelper

public DatabaseHelper(Context context,
                      java.lang.String dbFile,
                      CursorFactory factory,
                      int dbVersion)
Method Detail

onCreate

public void onCreate(SQLiteDatabase arg0)

onUpgrade

public void onUpgrade(SQLiteDatabase arg0,
                      int arg1,
                      int arg2)

loadDatabase

public void loadDatabase(java.net.URL location)
                  throws java.lang.Exception
Caution: Overwrites existing application database. Make sure the new database is an existing SQLite database. The database must follow the conventions of the corresponding database adapter.

Parameters:
location - the location of the new database
Throws:
java.io.IOException
java.lang.Exception

loadDatabase

public void loadDatabase(java.io.InputStream inputstream)
                  throws java.lang.Exception
Caution: Overwrites existing application database. Make sure the new database is an existing SQLite database. The database must follow the conventions of the corresponding database adapter.

Parameters:
inputstream - stream from existing database
Throws:
java.lang.Exception

exportDatabase

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

Throws:
java.io.IOException
java.net.MalformedURLException
java.lang.Exception