I want to get an image and store it in sqlite what should I do?
For example user clicks on button and picks an image from gallery now I want to store it in sqlite and show that image on another one activity.
I want to get an image and store it in sqlite what should I do?
For example user clicks on button and picks an image from gallery now I want to store it in sqlite and show that image on another one activity.
In android Phones due to their nature its not a good idea to store images in the Database since it is not thread safe storing byte to byte of the Images. Also its complicated to pass a Bitmap to another Activity and it can lead to Memory Errors.
It may make your app slow an even get ANR (Application Not Responding
) errors, So if you want to store Images just store their File path
to the folder they are found or Uri
to their location.
You need some training to ways to get Uri
when guiding user to pick the Image which is not under the scope of this question. So consider visiting this question. Also also this external link.