//DATA BASE NAVRUZ TOSHKANOV ON CREATE
package uz.navruz.database
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.provider.BaseColumns
class DatabaseHelper(context: Context) : SQLiteOpenHelper(context, "User.db", null, 1) {
override fun onCreate(db: SQLiteDatabase?) {
val userTable = "CREATE TABLE ${DatabaseContainer.TABLE_NAME} (" +
"${BaseColumns._ID} INTEGER PRIMARY KEY AUTOINCREMENT," +
"${DatabaseContainer.FIRSNAME} TEXT," +
"${DatabaseContainer.LASTNAME} TEXT," +
"${DatabaseContainer.AGE} INTEGER," +
"${DatabaseContainer.COURSE} INTEGER)"
db!!.execSQL(userTable)
}
override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
db!!.execSQL("DROP TABLE IF EXISTS ${DatabaseContainer.TABLE_NAME}")
}
}
Do'stlaringiz bilan baham: |