Android: Difference Between A System Resource And An Application Resource?
Solution 1:
System Resources:
Android OS by default as has some resources which it uses in many places like cancel
and ok
strings. Event image resources like close
icon and many more. One can use the directly in your application by getting that resource. As it's static, so can use it Absolutely everywhere
Resources.getSystem().getString(android.R.string.cancel);//for system resources only
- For System resources you use
android.R.
(anim, color, string, id, drawable)
Application Resources:
In your application you have many strings which you use it in many UI Components which is meant to change dynamically on the scenario basis for that purpose you're going to use your application resources. You need a context
to get that application resources as it's not static one.
getApplicationContext().getResource().getString(R.string.cancel);//cancel string which you've define in values/strings.xml
- For application you use
R.
(anim,drawable,id,string,color)
Solution 2:
Application resources are
- Animation Resources (R.anim) --> res/anim
- Color State List Resource(R.color) --> res/color
- Drawable Resources (R.drawable) --> res/drawable
- Layout Resource (R.layout) -- >res/layout
see this link for more details
System resources are
- Android ids (android.R.id)
- Android's widgets (android:id/tabs)
- Color (android.R.color.transparent)
see this post for more details
Post a Comment for "Android: Difference Between A System Resource And An Application Resource?"