de.theappguys.winzigsql
Class WinzigDbScriptHelper

java.lang.Object
  extended by android.database.sqlite.SQLiteOpenHelper
      extended by de.theappguys.winzigsql.WinzigDbScriptHelper

public class WinzigDbScriptHelper
extends android.database.sqlite.SQLiteOpenHelper

Extension of SQLiteOpenHelper that handles initialization & upgrade of the database based on naming conventions for resources in the asset files. Works hand-in-hand with the WinzigDbProvider


Field Summary
static String LOG_TAG
           
 
Constructor Summary
WinzigDbScriptHelper(android.content.Context context, String dbName, int dbVersion)
          Let your custom db provider extends this class and call the superconstructor like so:
 
Method Summary
 boolean dropDb()
          Only for debugging purposes.
 void onCreate(android.database.sqlite.SQLiteDatabase db)
          (non-Javadoc)
 void onOpen(android.database.sqlite.SQLiteDatabase db)
          We override onOpen to enable foreign keys.
 void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)
          (non-Javadoc)
 
Methods inherited from class android.database.sqlite.SQLiteOpenHelper
close, getReadableDatabase, getWritableDatabase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_TAG

public static final String LOG_TAG
See Also:
Constant Field Values
Constructor Detail

WinzigDbScriptHelper

public WinzigDbScriptHelper(android.content.Context context,
                            String dbName,
                            int dbVersion)
Let your custom db provider extends this class and call the superconstructor like so:

 private MyDbHelper(final Context context) {
     super (context, "myDbName", 42);
 }
 
Then, to obtain instances, implement a get Instance method like this:

 private static MyDbHelper instance = null;

 public static MyDbHelper(final Context context) {
     if (instance == null) {
         return (instance = new MyDbHelper(context))
     } else {
         return instance;
     }
 }
 

Method Detail

onCreate

public void onCreate(android.database.sqlite.SQLiteDatabase db)
(non-Javadoc)

Specified by:
onCreate in class android.database.sqlite.SQLiteOpenHelper
See Also:
SQLiteOpenHelper.onCreate(android.database.sqlite.SQLiteDatabase)

onUpgrade

public void onUpgrade(android.database.sqlite.SQLiteDatabase db,
                      int oldVersion,
                      int newVersion)
(non-Javadoc)

Specified by:
onUpgrade in class android.database.sqlite.SQLiteOpenHelper
See Also:
SQLiteOpenHelper.onUpgrade(android.database.sqlite.SQLiteDatabase, int, int)

onOpen

public void onOpen(android.database.sqlite.SQLiteDatabase db)
We override onOpen to enable foreign keys.

Overrides:
onOpen in class android.database.sqlite.SQLiteOpenHelper

dropDb

public boolean dropDb()
Only for debugging purposes.

Returns:
true: db was deleted.


Copyright © 2013. All Rights Reserved.