SQLiteOpenHelper A helper class to manage database creation and version management.You create a subclass to takes care of opening the database
if it exists, creating it if it does not, and upgrading it as necessary.
class MyDbHelper implements SQLiteOpenHelper { ...... } SQLiteOpenHelper dbHelper = new MyDbHelper(context, xxx); SQLiteDatabase db = dbHelper.dbHelper.()
SQLiteDatabase Exposes methods to manage a SQLite database:create, delete, execute SQL commands, and perform other common database management tasks.
insert row(s) (depend on ContentValues. ContentValues object represents a row in table, call ContentValues.put to set value of each column. more sample: http://developer.android.com/guide/topics/providers/content-providers.html#modifying)
replace
update
query (query or rawQuery)
execSQL
getPath
setLockingEnabled Control whether or not the SQLiteDatabase is made thread-safe
xxx
Datebase class to process datebase, table. You can get an instance of SQLiteDatabase through 2 ways: a) SQLiteDatabase db = context.openOrCreateDatabase(, ); b) Implement the interface SQLiteOpenHelper, and then create its instance, class MyDbHelper implements SQLiteOpenHelper { public void onCreate (SQLiteDatabase db) { final String str = "CREATE TABLE IF NOT EXIST tab_name(col_id INTEGER PRIMARY KEY, col_name, TEXT NOT NULL)"; db.execSQL(str); } ......
} SQLiteOpenHelper dbHelper = new MyDbHelper(context, xxx); SQLiteDatabase db = SQLiteDatabase.()
xxx
Tools
sqlite3
launch $adb shell $sqlite3 sqlite>
Use sqlite command sqlite>.help
Exec SQL sqlite>SELECT * FROM WHERE xxx
xxx
xxx
tips:
Get path of database: context.getDatabasePath("dummy").getParent(); //'dummy' is the name of a inexisting db