Answer the question
In order to leave comments, you need to log in
How to store images in sqlite android?
You need the ability to attach pictures to notes (1 or more).
Notes are stored in the database in String.
And how to organize the storage of images?
Use an array of strings in which to store the addresses of the pictures?
Where are the pictures stored? In the application folder on the phone or on the flash drive?
Answer the question
In order to leave comments, you need to log in
for those who store pictures in the database there is a separate frying pan !!! Cases when this may be necessary can be read on the fingers.
Store paths in the database.
Storing a list of paths, names, or their hashes in a database is common practice.
It is possible to store on a flash drive, no - in the internal memory.
in Base64 format you can save in database. Here is an example:
//конвертируем Bitmap на Base64
public String convertToBase64(Bitmap bitmap) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100,os);
byte[] byteArray = os.toByteArray();
return Base64.encodeToString(byteArray, 0);
}
//и наоборот
public Bitmap convertToBitmap(String base64String) {
byte[] decodedString = Base64.decode(base64String, Base64.DEFAULT);
Bitmap bitmapResult = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return bitmapResult;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question