简体   繁体   中英

How to manage resource in Android

Hi i just start wonder what is better. Always load small data from resources (like dimension, color etc.) or load once when it's neede and put it on some HasMap.

  • I have grid layout. Size : 7*7 so i have 49 items.
  • Every item have special date like: color, dimension, some drawable, some font size.
  • This is a representation of single level. So when user passed level 1, before start level 2 everything is loaded from resources again.

So my question is:

What is better?

1) Always load data from resources. 2) Load data from resources when it's needed. Put this data to HasMap and when we need this resource again, load from this HasMap instead of load from resources.

Depends on how many times you are accessing the resources for eg; if by moving from level 1 to level 2, you are not allowing user to go back to level 1, then it is advised to use resources only, but if there are frequent movements between level 1 and level 2, then storing them in hashmap, would be good, because you would have the hashmaps already ready to be used somewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM