Advertisement
Guest User

StudentsDb

a guest
Nov 28th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public class StudentsDb {
  2. //рікнародження,місце,факультет курс
  3. public static final String KEY_ROWID = "_id";
  4. public static final String KEY_CODE = "code";
  5. public static final String KEY_NAME = "name";
  6.  
  7. public static final String KEY_YEAR = "year";
  8. public static final String KEY_PLACE = "place";
  9. public static final String KEY_COURSE = "course";
  10.  
  11. public static final String KEY_FACULTET = "facultet";
  12.  
  13. private static final String LOG_TAG = "StudentsDb";
  14. public static final String SQLITE_TABLE = "Student";
  15.  
  16. private static final String DATABASE_CREATE =
  17. "CREATE TABLE if not exists " + SQLITE_TABLE + " (" +
  18. KEY_ROWID + " integer PRIMARY KEY autoincrement," +
  19. KEY_CODE + "," +
  20. KEY_NAME + "," +
  21. KEY_FACULTET + "," +
  22. KEY_YEAR + "," +
  23. KEY_PLACE + "," +
  24. KEY_COURSE + "," +
  25. " UNIQUE (" + KEY_CODE +"));";
  26.  
  27. public static void onCreate(SQLiteDatabase db) {
  28. Log.w(LOG_TAG, DATABASE_CREATE);
  29. db.execSQL(DATABASE_CREATE);
  30. }
  31.  
  32. public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  33. Log.w(LOG_TAG, "Upgrading database from version " + oldVersion + " to "
  34. + newVersion + ", which will destroy all old data");
  35. db.execSQL("DROP TABLE IF EXISTS " + SQLITE_TABLE);
  36. onCreate(db);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement