I have an activity in my app that has a recycler view. The recycler view creates items programaticly, dependence on a number of JSON files in the RAW
folder. so lets say if I have 5 JSON files in RAW
it will create 5 items, if it has 7 then it will create 7 items. the JSON file looks something like that:
{
"info": {
"metadata1": "x",
"metadata2": "y"
},
"data": {
"field1": "a",
"field2": "b"
}
}
So, the recycler view only needs the "info"
part of the JSON. then when you click an item, you go to another activity that needs alk the "data"
part of the JSON. right now what I am doing is every time a user enters the recycler view it open and reads all the raw
files, every time, and then when the user enters to the specific item it opens and reads the specific json every time.
I think it causes a lot of overhead to the system and a waste of read/open actions, so I thought I should use some kind of cache mechanism to load only one time all the JSON files at the beginning, but then on the other hand, I also think it will use too much memory during runtime.
what is the best way to design this thing and is there a way to use a cache mechanism?
Aucun commentaire:
Enregistrer un commentaire