I'm developing an app that spans across several classes, and as such, I've had to pass on the app's Context to all of the classes that use global strings or integers so as to extract them from the strings.xml or dimens.xml files instead of hard coding them. Up until now I've been loading the resources once needed but I was wondering if it would be more efficient to load all the resources I would need on a class in the Constructor, keep in mind that they're only strings and integer values.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
For small Objects (Strings, Numbers) you can preload them as it wouldn't take much memory.
For big Objects (Images,Media) it is better to load as needed.
My personal preference for small Objects is to lazy load them (load as needed but after loading keep in memory for later use), something like:
As, noticed I use it for sorts of small objects, for Strings (especially local Resources) it is more of a bother to load them like this, just load them once at begining (if you have defined them then it is more likely they will be used).