Read More
Read now

Downloading files using volley.

Save

The files in android can be saved in either internal and external memories.By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.

While files stored to the external storage are shareable and can be modified.

That is why the files that are specific for the application for example, additional resources downloaded by your app or temporary media files, are saved in internal storage. There are various ways to download a file but here we are going to download the file using volley.

Firstly you have to create your own custom request class like

Now just send request though our custom class with Request.Method.GET and the url from where you want to doenload the file.

Now go to your application folder data/data/<your_application>/<file_name> and there is your file you can also download the file to external stoage.

You can access the files in internal storage using

It returns the file with that name from the internal directory of application and null if there is no file with such name. Dont forget to add extenion of the file with the name.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


12 comments

  • Abir Hasan
    great tutorial, thanks 😀
    • aastha gupta
      Thank you 😀
  • Muhammad Hamza
    Thanks for the tutorial.Cannot resolve function openFileOutput().Can please share the code for the function
    • Muhammad Hamza
      sorry my bad calling from an inner class have to use context.openFileOutput() issue resolved thanks any ways
  • Sakshi singhal
    cant understand how to use it
  • Thais Sandim
    Thank you!
    Works fine
  • daddy
    “super(post, mUrl, errorListener);” should be “super(method, mUrl, errorListener);”
  • Mahdi
    Works like a charm 🙂 Thanks
  • Ranjithkumar R
    In our “custom request class” line no:12, “post” indicates which one?
    • anchit (Moderator)
      Well actually the post is for the method integer that tell us the method type of the Http requestv (namely-> GET, POST).

      I will correct the same in the content right away.

  • Sekhar
    Thank You.
    • anchit (Moderator)
      Your Welcome
  • css.php

    Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

    Deniel Kerr

    Owner and Founder. Opencart

    Talk to Sales
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home