public abstract class CopiedDataBaseHelper
extends android.database.sqlite.SQLiteOpenHelper
Constructor and Description |
---|
CopiedDataBaseHelper(android.content.Context context,
java.lang.String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version)
Required constructor
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkDataBase()
Check if the database already exist to avoid re-copying the file each time you open the application.
|
void |
close()
close the database
|
protected void |
copyDataBase()
Copies your database from your local assets-folder to the just created empty database in the system folder, from
where it can be accessed and handled.
|
void |
createDataBase()
Creates the database
|
void |
onCreate(android.database.sqlite.SQLiteDatabase arg0)
Invoked onCreate
|
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
called on database upgrade
|
void |
openDataBase()
Opens the database
|
protected 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)
Runs a query on the real database
|
public CopiedDataBaseHelper(android.content.Context context, java.lang.String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int version)
context
- contextdatabaseName
- database namefactory
- cursor factoryversion
- database versionpublic void createDataBase()
protected boolean checkDataBase()
protected void copyDataBase() throws java.io.IOException
java.io.IOException
public void openDataBase() throws android.database.SQLException
android.database.SQLException
- while opening the databasepublic void close()
close
in interface java.lang.AutoCloseable
close
in class android.database.sqlite.SQLiteOpenHelper
public void onCreate(android.database.sqlite.SQLiteDatabase arg0)
onCreate
in class android.database.sqlite.SQLiteOpenHelper
arg0
- databasepublic void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)
onUpgrade
in class android.database.sqlite.SQLiteOpenHelper
db
- databaseoldVersion
- oldversionnewVersion
- newversionprotected 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
- table namecolumns
- columnsselection
- selectionselectionArgs
- selectionargsgroupBy
- groupbyhaving
- having clauseorderBy
- orderby