-2

I want to download the image from URL internet to local storage and open the image from local storage to imageview ?

I saw these answers

How to download and save an image in Android

Download images and save it

downloading images with Picasso android disck

Saving image from URL using Picasso?

I know we can use Picasso and Glide and Volley and Universal Image Loader to do these job and there are other libraries also ...

but I can't implement the code of download image ! and can't find any new example of on the internet. I found some old example of Picasso library old version

can you give me the new code of download image from URL internet to local storage or any tutorial talk about this topic

Eby Jacob
  • 1,418
  • 1
  • 10
  • 28
Abdullah Jacksi
  • 209
  • 6
  • 19
  • And what is the problem with all of the links you shared? [The very first link](https://stackoverflow.com/a/15549639/1790644) appears to be pretty comprehensive.... – Matt Clark May 09 '18 at 22:32
  • @Matt Clark i can't implement the code of download image ! ... and can't find any new example of on internet ... i found some old example of Picasso library old virsion – Abdullah Jacksi May 09 '18 at 22:36
  • Why can you not implement it? What could you possibly mean by you cant find any new examples? That post has the exact code to do the download... – Matt Clark May 09 '18 at 22:38
  • @Matt Clark like in picasso, this is old version Picasso.with(MainActivity.class).load(myPhoto).into(picassoImageTarget(getApplicationContext(), "imageDir", "my_image.jpeg")); – Abdullah Jacksi May 09 '18 at 22:42
  • And you still have not explain what you problem is, or why you can not implement these solutions.Maybe you should just go [read the docs for Picasso](http://square.github.io/picasso/). – Matt Clark May 09 '18 at 22:45
  • @Matt Clark i can't find any example of download image from URL to local storage in docs of Picasso – Abdullah Jacksi May 09 '18 at 22:48
  • You can try this code for downloading a URL of an image and save it in internal storage https://stackoverflow.com/a/14648729/7269831 Also, you can download files using DownloadManager like this code: https://stackoverflow.com/a/21276803/7269831 – Mohammed Jacksi May 09 '18 at 23:00

2 Answers2

1

Try this one ...

Use this gradle : https://github.com/amitshekhariitbhu/Fast-Android-Networking

and check this point : Downloading a file from server

Dhara Jani
  • 461
  • 3
  • 10
0

Use download Manager to download image from link(From Internet)

DownloadManager downloadManager = (DownloadManager) ((Activity) context).getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
            .setAllowedOverRoaming(false)
            .setTitle(fileName)
            .setDescription("file description")
            .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
            .setDestinationInExternalPublicDir(imgStoragePath, fileName)
            .setVisibleInDownloadsUi(true);

    BroadcastReceiver onComplete = new BroadcastReceiver() {

        public void onReceive(Context ctxt, Intent intent) {

            //Download complete 

        }
    };
    context.registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    downloadManager.enqueue(request);
yatin deokar
  • 730
  • 11
  • 20