1

I created this database

 public void onCreate(SQLiteDatabase db) {
    String query="CREATE TABLE "+tableName+" ( ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
            col1+" INTEGER, "+col2+" String, "+col3+" String, "+col4+" String );";
    db.execSQL(query);
}

to sotre an image with some informations in a list I get the image from the user

public void openGallery(View view){
    Intent open = new Intent(Intent.ACTION_GET_CONTENT);
    open.setType("image/*");
    startActivityForResult(open,100);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode==RESULT_OK && requestCode==100){
        Uri uri = data.getData();
        try {
            InputStream inputStream = getContentResolver().openInputStream(uri);
            Bitmap decodeStream = BitmapFactory.decodeStream(inputStream);
            img.setImageBitmap(decodeStream);
        } catch (FileNotFoundException e) {
            Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
        }

    }



}

and I put the image in the variable "img" > img.setImageBitmap(decodeStream);

how do I save it in the database base ?

0 Answers0