Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to save images which comes from server in android

I am working on one application and getting product images from the server. Currently I am saving those images into the SQLite database after converting them into byte array and at the time of use I convert them back into bitmap.

Now I have below two queries:

  1. What is the best way to save the images in app from where we can sync them also and get when ever required.

  2. How to assign them on image view or button because sometimes memory issue arises and application stop suddenly.

Please guide me. Any help is appreciated.

like image 228
Simple Avatar asked Oct 23 '25 08:10

Simple


1 Answers

Storing app specific things on SD Card may not be the right way.. You should store images on

// it will reside in data/data/com.package.name 
String path = getApplicationContext().getFilesDir() + "/";
File imagesFolder = new File(path);
imagesFolder.mkDir();

and put image files here in that folder.. So SD Card dependency can be removed.

like image 120
aditya Avatar answered Oct 24 '25 22:10

aditya