Reputation: 1272
My goal is to download multiple images from given url's and save them into interal storage.
private void downloadImages(List<String> filename,JSONObject c) throws Exception{
String fileName = c.getString("name") + ".json";
String data = "";
File images = getDir("Images", Context.MODE_PRIVATE);
File dir = new File(images,fileName);
System.out.println(dir.getAbsolutePath());
List<Bitmap> pictures = new ArrayList<>();
for(String s : filename){
}
}
The List<String> filename
contain all the url's from the images.
So what i think i have to do is, to download the image for each url in filename
The structure is like this :
Images
------fileName
--------------Image1
--------------Image2
------fileName2
--------------Image1
--------------Image2
I would like to use this :
AsyncHttpClient client = new AsyncHttpClient();
client.get("https://example.com/file.png", new FileAsyncHttpResponseHandler(/* Context */ this) {
@Override
public void onSuccess(int statusCode, Header[] headers, File response) {
// Do something with the file `response`
}
});
Upvotes: 0
Views: 338
Reputation: 641
Try this awesome lib provided by facebook Fresco powerful image caching and downloading.
Upvotes: 3
Reputation: 437
Do you need to see the images or use the images? if you just want to use the images then reinventing the wheel is no the way to go try using a library instead of implementing your own thing it will save you alot of stress and time try either Picasso or Universal Image Loader all that stuff is done for you.
Upvotes: 0
Reputation: 835
Please take a look at the following link: http://denniskubes.com/2012/11/16/android-image-downloading-and-caching/
Upvotes: 0