Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StudentsDb {
- //рікнародження,місце,факультет курс
- public static final String KEY_ROWID = "_id";
- public static final String KEY_CODE = "code";
- public static final String KEY_NAME = "name";
- public static final String KEY_YEAR = "year";
- public static final String KEY_PLACE = "place";
- public static final String KEY_COURSE = "course";
- public static final String KEY_FACULTET = "facultet";
- private static final String LOG_TAG = "StudentsDb";
- public static final String SQLITE_TABLE = "Student";
- private static final String DATABASE_CREATE =
- "CREATE TABLE if not exists " + SQLITE_TABLE + " (" +
- KEY_ROWID + " integer PRIMARY KEY autoincrement," +
- KEY_CODE + "," +
- KEY_NAME + "," +
- KEY_FACULTET + "," +
- KEY_YEAR + "," +
- KEY_PLACE + "," +
- KEY_COURSE + "," +
- " UNIQUE (" + KEY_CODE +"));";
- public static void onCreate(SQLiteDatabase db) {
- Log.w(LOG_TAG, DATABASE_CREATE);
- db.execSQL(DATABASE_CREATE);
- }
- public static void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- Log.w(LOG_TAG, "Upgrading database from version " + oldVersion + " to "
- + newVersion + ", which will destroy all old data");
- db.execSQL("DROP TABLE IF EXISTS " + SQLITE_TABLE);
- onCreate(db);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement