I'm working on an app that will retrieve a colors.json file from server. This file will have the following structure:
[
{"ServerActionButton.background.normal":
{ "red": 29, "green": 188, "blue": 189, "alpha":255}
},
{"ServerActionButton.background.disabled":
{ "red": 164, "green": 228, "blue": 229, "alpha":255}
},
{"ServerActionButton.title.normal":
{ "red": 255, "green": 255, "blue": 255, "alpha":255}
},
...
]
This JSON should be retrieved on app startup, and I should be able to use these colors throughout the whole app.
Question: What's the best way to do this? I've thought about the following options:
- Generating a resource XML file from the JSON (it would be great, but is it possible?).
- Mapping the JSON to a model, and then storing it in SharedPreferences.
- Building a local database with the data retrieved from the JSON.
Which would be the best approach? Is there some other possibility I'm not considering?
Thanks in advance!