¡@

Home 

2014/10/16 ¤W¤È 08:24:55

android Programming Glossary: sqlitedb

How to initialize sqlite database once from a helper class in Android

http://stackoverflow.com/questions/7444327/how-to-initialize-sqlite-database-once-from-a-helper-class-in-android

import android.util.Log public class DataBaseHelper extends SQLiteOpenHelper private static SQLiteDatabase sqliteDb private static DataBaseHelper instance private static final int DATABASE_VERSION 1 the default database path is data data.. create instance of database databaseName instance new DataBaseHelper context databaseName null DATABASE_VERSION sqliteDb instance.getWritableDatabase Log.i TAG instance of database databaseName created Static method for getting singleton.. return instance Method to get database instance @return database instance public SQLiteDatabase getDatabase return sqliteDb @Override public void onCreate SQLiteDatabase db Log.d TAG onCreate nothing to do @Override public void onUpgrade SQLiteDatabase..