public class SQLiteHelper
extends SQLiteOpenHelper
Modifier and Type | Field and Description |
---|---|
protected Context |
mContext |
protected SQLiteDatabase |
mDb |
protected java.lang.String |
mSystemPath |
protected static java.lang.String |
TAG |
Constructor and Description |
---|
SQLiteHelper(Context context,
java.lang.String dbName)
Constructor Takes and keeps a reference of the passed context in order to access to the application assets and resources.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkAndCreate(java.lang.String assetPath,
java.lang.String systemPath)
Creates a empty database on the system and rewrites it with your own database.
|
void |
close() |
protected void |
copy(java.lang.String assetPath,
java.lang.String systemPath)
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.
|
static boolean |
isExisting(java.lang.String systemPath)
Check if the database already exist to avoid re-copying the file each time you open the application.
|
void |
onCreate(SQLiteDatabase db) |
void |
onUpgrade(SQLiteDatabase db,
int oldVersion,
int newVersion) |
void |
open(java.lang.String systemPath) |
protected static final java.lang.String TAG
protected SQLiteDatabase mDb
protected final Context mContext
protected java.lang.String mSystemPath
public SQLiteHelper(Context context, java.lang.String dbName)
context
- public boolean checkAndCreate(java.lang.String assetPath, java.lang.String systemPath)
public static boolean isExisting(java.lang.String systemPath)
protected void copy(java.lang.String assetPath, java.lang.String systemPath) throws java.io.IOException
java.io.IOException
public void open(java.lang.String systemPath) throws SQLException
SQLException
public void close()
public void onCreate(SQLiteDatabase db)
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)