39

I will be using a local JSON file with some data. My question is where is the best/proper way to store the file and how should I access it and it's contents?

I have worked with json through http before but not a local one.

4
  • Your question isn't clear about whether the JSON file should be shipped as part of your app. If yes, ranjk89's answer is correct. Commented May 22, 2014 at 13:37
  • Yes, it will be part of the app. Commented May 22, 2014 at 13:38
  • Will the json file be always the same or do you plan to change it with your up while running? If it is going to be static use assets folder if not use the local storage of the device. Commented May 22, 2014 at 13:44
  • It will always be the same Commented May 22, 2014 at 13:47

1 Answer 1

47

There are so many ways,

For basic JSON parsing, Android's in-built JSONObject should work - https://developer.android.com/reference/org/json/JSONObject.html

For more advanced JSON parsing (json-java mapping), you can look at GSON library - https://code.google.com/p/google-gson/

Sign up to request clarification or add additional context in comments.

1 Comment

Is any of ways above better than the other? Or does both work as good?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.