Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Database & Table creation:
- SQLiteDatabase db;
- try{
- SQLiteDatabase dbe = SQLiteDatabase.openDatabase("/data/data/bangla.rana.fahim/databases/dictionary", null,0);
- dbe.close();
- }
- catch(SQLiteException e){
- db = openOrCreateDatabase("dictionary", MODE_PRIVATE, null);
- db.execSQL("CREATE TABLE IF NOT EXISTS LIST(wlist varchar,ex varchar);");
- db.close();
- }
- Inserting values in table:
- db.execSQL("INSERT INTO LIST VALUES('খবর');");
- After completion of work close the database as:
- db.close();
- Retrieving data using cursor:
- db = SQLiteDatabase.openDatabase("path to your database", null,0);
- String q = "SELECT * FROM LIST where( wlist like '"+mComposing.toString()+"%')"+"ORDER BY wlist"; //your wanted query
- Cursor c = db.rawQuery(q, null);
- c.moveToFirst();
- do {
- //do whatever you like
- } while (c.moveToNext());
- Close cursor & database:
- c.close();
- db.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement