Alright, as Lingviston already pointed out. You can implement picking an image from the gallery from here.
As for storing the image, I'm going to edit the code in the link a little bit.
Instead of this:
ImageView imageView = (ImageView) findViewById(R.id.imgView);
imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));
I'm going to store the selected image in a Bitmap
.
ImageView imageView = (ImageView) findViewById(R.id.imgView);
Bitmap mBitmap = BitmapFactory.decodeFile(picturePath);
imageView.setImageBitmap(mBitmap);
Now to store in as a BLOB
type in android you need to convert the bitmap into bytes and then store the byte array in the sqlite database.
ByteArrayOutputStream stream = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] imageInByte = stream.toByteArray();
Now you just need to pass imageInByte
to store in the SQLite
database.
As a side note, both of these answers were already available all over the internet and StackOverflow
individually, you just had to put 2 and 2 together. Please try searching thoroughly before you post a question.