0

I am using an application which parse remote json into a list view and it works fine as single activity and if the device is online..

Is there a way to download the json data locally(cached) in the device and then pull it inside my app inside Listviews.. i am planning to have multiple listviews which takes the data from the same json file and then filter them out based on some criteria such as location then allow user to swipe the app for different views.

I appreciate your advices,

Abdul

Alzaabi98
  • 35
  • 1
  • 9
  • Maybe this is the right answer: http://stackoverflow.com/questions/21460461/how-to-cache-json-data-to-be-available-offline – Ivan Seidel Oct 29 '14 at 03:46

2 Answers2

0

You can store the data in SharedPreference. Check this out

And also, there are more Storage Options for you.

Lei
  • 22
  • 3
  • I think shared preference is only used for small data not for huge information. The json file has more information for each item.. I don't think it will work using preference. unless there are diff type of preference. – Alzaabi98 Oct 29 '14 at 05:15
0

I have one idea , i hope it will work for you

  1. Store content of file in Object that is in cache in form of JSON .
  2. Now Object have all your content which you can pass to JsonArray or JsonObject to parse.

     File file = new File("C:/ciphertext.txt");
    int ch;
    StringBuffer strContent = new StringBuffer("");
    FileInputStream fin = null;
           try {
    fin = new FileInputStream(file);
    while ((ch = fin.read()) != -1)
    strContent.append((char) ch);
    fin.close();
    } catch (Exception e) {
    System.out.println(e);
     }
    

Now our strContent have content of file.

DJhon
  • 1,548
  • 3
  • 22
  • 39
  • thanks for your answer. can you elaborate more in this.. which object cane be cached. can you provide example as I am new to android world :) – Alzaabi98 Oct 29 '14 at 05:16