I’m working on a little Android project in java, I’m using the webapi of spotify to get me so data to play around with.
First thing I notice when visiting: https://developer.spotify.com/technologies/web-api/ is that a developer can choose to use xml or json.
What i would like to do is ‘cache’ my data so i can do the following:
- read one value from the file, or construct an object based on different values
- add the object created above to the lisviewadapter
- update the listview with the updated adapter
- iterate over previous steps until parsing of file is complete
I want to be as quick as possible for my users so that the ui gets updated while parsing and loading the data. For this I sketched 2 use-cases.
- add items to the listview until done
- show a X amount of items and show a load more button
What file type is more ideal to use for my problem? xml parsing or json parsing?
How can i do this parsing? which tools meet my requirements?
Which use-case seems better to use?
any tips if you have done something like this in the past?
any guidance is appreciated
I don’t make any distinction between XML or JSON. To cache data you have two options. Either write the data to a file (will require reparsing of the file to extract the data (unless you create a new file of, for example, CSV data)) or write the required data to a database after parsing. As for updating
ListView, that would be up to you based on the number of entries you have.Android has both XML and JSON parsers built-in. You don’t need GSON.