How To Store Image Location (fetching From Filepicker/intent) In Sqlite
I am new to Android Development. I am trying to store Image file location in Sqlite database. Image is received from Intent with any file manager or gallery. I want to store its re
Solution 1:
You can store an image in database as bytearray or also store image URL as TEXT in sqlite dataBase
Solution 2:
Try this
Intent name=newIntent(Intent.ACTION_GET_CONTENT);
name.setType("image/*.png"); // It could be any files extension that your going to searchstartActivityForResult(name, requestCode);
And also Override onActivityResult() method
@OverrideprotectedvoidonActivityResult(int requestCode, int resultCode, Intent data)
{
String path=data.getData().getPath();
//Here insert the path into database
}
Solution 3:
You can save the image path and always check if the path is valid or exists.
You can use an intent to pick up the image:
Intentintent=newIntent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, PICK_IMAGE_REQUEST_CODE);
And get the image path:
@Override
publicvoidonActivityResult(int requestCode, int resultCode, Intent data){
if (requestCode == PICK_IMAGE_REQUEST_CODE) {
/** You have to call the getData or getDataString to get the images address */
Log.i("CCC", data.getDataString());
}
}
With the path you can save it in the database.
Enjoy it!!
Post a Comment for "How To Store Image Location (fetching From Filepicker/intent) In Sqlite"