0

i have RecycleView from Json.

i want my button can download Url from specific file Json.

How to get file Url file from Json and implement to Button download?

my ui

Json

[
    {
        "name": "Naruto: Shippuuden",
        "description": "It has been two and a half years since Naruto Uzumaki left Konohagakure, the Hidden Leaf Village, for intense training following events which fueled his desire to be stronger. Now Akatsuki, the mysterious organization of elite rogue ninja, is closing in on their grand plan which may threaten the safety of the entire shinobi world.",
        "Rating": "8.16",
        "episode": 500,
        "categorie":"Animation | Drama | Adventure",
        "studio":"Studio Pierrot",
        "img": "https://myanimelist.cdn-dena.com/images/anime/5/17407.jpg",
        "file": "http://androhub.com/demo/demo.pdf"
    }]
Mind
  • 1
  • 5

1 Answers1

0

First you need to convert the String to JSON and parse it, you can use org.json to do it, more details can be found at How to convert String to JSONObject in Java

JSONObject jsonObj = new JSONObject("{\"phonetype\":\"N95\",\"cat\":\"WP\"}");

Then you need to download the data URL,more details can be found at How to download and save a file from Internet using Java?

URL website = new URL("http://www.website.com/information.asp");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("information.html");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
flyingfox
  • 13,414
  • 3
  • 24
  • 39