Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. //nama db
  2. public static String DATABASE_NAME = "notadb";
  3. //veri db
  4. private static final int DATABSE_VERSION = 1;
  5. //query create db
  6. private static final String SQL_CREATE_TABLE_NOTA = String.format("CREATE TABLE %s"
  7. +"(%s INTEGER PRIMARY KEY AUTOINCREMENT,"+
  8. "%s TEXT NOT NULL, "+
  9. "%s TEXT NOT NULL, " +
  10. "%s TEXT NOT NULL, )",
  11. DatabaseContract.TABLE_NOTA,
  12. DatabaseContract.NotaColum._ID,
  13. DatabaseContract.NotaColum.TITLE,
  14. DatabaseContract.NotaColum.DESKRIPSI,
  15. DatabaseContract.NotaColum.TANGGAL);
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. public DatabaseHelper(Context context) {
  23. super(context, DATABASE_NAME, null, DATABSE_VERSION);
  24. }
  25.  
  26. @Override
  27. public void onCreate(SQLiteDatabase db) {
  28. db.execSQL(SQL_CREATE_TABLE_NOTA);
  29.  
  30. }
  31.  
  32. @Override
  33. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  34. db.execSQL("DROP TABLE IF EXISTS"+DatabaseContract.TABLE_NOTA);
  35. onCreate(db);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement