daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyDBOpenHelper extends SQLiteOpenHelper {
  2.  
  3. private static final String queryCreationBdd = "CREATE TABLE partie (id INTEGER PRIMARY KEY)";
  4.  
  5. public MyDBOpenHelper(Context context, String name, CursorFactory factory, int version)
  6. {
  7.     super(context, name, factory, version);
  8. }
  9.  
  10. @Override
  11. public void onCreate(SQLiteDatabase db)
  12. {
  13.     db.execSQL(queryCreationBdd);
  14. }
  15.  
  16. @Override
  17. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
  18. {
  19.     db.execSQL("DROP TABLE partie;");
  20.     db.execSQL("DELETE FROM sqlite_sequence"); //table which contains the next incremented key value
  21.     onCreate(db);
  22. }
  23.  
  24. }
  25.    
  26. MyDBOpenHelper databaseHelper = new MyDBOpenHelper(context, "dbname.db", null, 1);
  27. SQLiteDatabase bdd = databaseHelper .getWritableDatabase();
  28.    
  29. /data/data/fr.mathis.application/databases/dbname.db
  30.    
  31. try{
  32.    SQLiteDatabase   dbe = SQLiteDatabase.openDatabase("/data/data/bangla.rana.fahim/databases/dictionary", null,0);
  33.             Log.d("opendb","EXIST");
  34.             dbe.close();
  35.             }
  36.    
  37. catch(SQLiteException e){
  38.                 Log.d("opendb","NOT EXIST");
  39.  
  40.             SQLiteDatabase db = openOrCreateDatabase("dictionary", MODE_PRIVATE, null);
  41.                     db.execSQL("CREATE TABLE IF NOT EXISTS LIST(wlist varchar);");
  42.  
  43.                     db.execSQL("INSERT INTO LIST VALUES('খবর');");
  44.                     db.execSQL("INSERT INTO LIST VALUES('কবর');"); //whatever you want
  45.                  db.close();
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top