I'm creating an android app and i have a relatively large amount of data (mostly in text form and as key->string pairs) that i want to display in my app. The problem is i don't want to enter the data in my app's code,meaning feel each TextView manually with the associated data.i don't feel that to be right! I want my app to read this data from a file(maybe a JSON?) and then associate each key-> string pair with the related TexView. To be more clear, i need to read from a prepared text file and use that text inside my app, AND i want to do this offline,i dont want to use any webservic How should i accomplish this? should i use a database or room?Then how should i feel the database manually without using insert codes inside the app?
You could simply use a JSON file. Now, the question is: How do you ship a JSON file with your app so that it's available at Runtime? You can use any of these methods:
Put it in the directory res/raw/
and read it using the Resources class (it has a openRawResource()
method)
Put it in the assets/
directory and read it in using the AssetManager class (it has a open()
method that returns an InputStream)
I hope this helps... Merry coding!