class DbHelper(var ctx:Context) : SQLiteOpenHelper(ctx,"My Datbase",null,1) {
override fun onCreate(db: SQLiteDatabase?) {
var create_table = "CREATE TABLE CATOGERIES (_Id INTEGER PRIMARY KEY AUTOINCREMENT , NAME STRING,IMAGE BLOB)"
db?.execSQL(create_table)
}
override fun onUpgrade(p0: SQLiteDatabase?, p1: Int, p2: Int) {
}
fun insertData(catogeries: Catogeries,db:SQLiteDatabase)
{
var dbHelper = this.writableDatabase
var value = ContentValues()
value.put("Name",catogeries.name)
value.put("Image",catogeries.Image)
db.insert("Catogeries",null,value)
}
private lateinit var Title: EditText
private lateinit var imageBtn: Button
var CameraRequestCode :Int = 200
var GalleryRequestCode :Int = 100
private lateinit var _addBtn: Button
var db = DbHelper(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val img = data?.extras?.get("data")
GotImage.setImageBitmap(img as Bitmap)
}
}
GalleryRequestCode->
{
if(resultCode== RESULT_OK)
{
var URI = data!!.data
var Image = MediaStore.Images.Media.getBitmap(this.contentResolver,URI)
GotImage.setImageBitmap(Image)
0 Answer(s)