Using local json file in Android

后端 未结 1 1169
攒了一身酷
攒了一身酷 2020-12-28 14:01

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 hav

相关标签:
1条回答
  • 2020-12-28 14:48

    There are so many ways,

    • You can store your JSON file in assets folder and read them like this - https://stackoverflow.com/a/19945484/713778

    • You can store it in res/raw folder and read the same as show here - https://stackoverflow.com/a/6349913/713778

    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/

    0 讨论(0)
提交回复
热议问题