Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Questions
Tags
Users
sign up
Badges
Unanswered
log in
Ask
java
android
json
offline
I have parsed the JSON Data in a listview and now I want to make it available offline. Is there a way to save the JSON data at the phone so that
you can see the data if your phone is offline?
Does someone knows an example?
EDIT works now:
share
Asked
Jan 30 '14 at 15:22
Brian Tompsett -
2,769 10 21 58
Edited
Dec 16 '15 at 15:54
You can save it to phone database. Search for it. Gokhan Arik Jan 30 '14 at 15:24
add a comment
5 Answers
order by votes
You have two ways. Either you create a database and save all of the data there and retrieve it back when you want to. Or if the data
you have is not that much and you don't want to deal with databases, then you write the json string to a text file in the memory card
share
27 54
Answered
Jan 30 '14 at 15:25
Depending on the JSON (if it is couple of entries), @user3241084 can use SharedPreferences. Yordan Lyubenov Jan 30 '14 at 15:40
@YordanLyubenov considering that user wants to store JSON object programatically when it's offline, I don't think it's just a couple of entries. osayilgan
Jan 30 '14 at 16:11
how can I add this to my code? I just tried but nothin worked? user3241084 Jan 30 '14 at 16:11
just deleted the wrong code that my app runs ;) user3241084 Jan 30 '14 at 16:21
e.printStackTrace();
share
share
Once you download the data you could persist the data on the mobile, using a database or a system of your preference.
You can check the different options here: data-storage
Answered
Jan 4 at 6:42
Javier Salinas
391 1 12
Answered
Jan 30 '14 at 15:26
you can use those two methods two store you JSON file as a string in your SharedPreferences and retrieve it back:
share
68 106
Answered
Jan 30 '14 at 15:31
Edited
Jan 30 '14 at 15:39
using SharedPreferences should be prepared to sqlite (unless of course you have a database structure). For caching and storing
data pulled from the internet, I recommend robospice: https://github.com/octo-online/robospice. It's a very well done library, easy to
use, and should be used any time you download data from the internet or have a long-running task.
share
Your Answer
log in
or
Name
Answered
Apr 23 '14 at 16:49
By posting your answer, you agree to the privacy policy and terms of service.
meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc