Developers can access, in addition to application resources, Android system resources. You can share many system resources across multiple applications for a common look and feel. For example, the Android system string resource class (android.R.string) contains strings for words such as OK, Cancel, Yes, No, Cut, Copy, and Paste.
To keep your application small and efficient, always check out the system resources before adding generic resources to your project.
System resources are stored within the android package. There are classes for each of the major resource types.
For example, the android.R.string class contains the system string resources. To retrieve a system resource string for ok, for example, you first need to use the static method of the Resources class called getSystem() to retrieve the global system Resource object. Then you can call the getString() method with the appropriate string resource name, like this:
String confirm = Resources.getSystem().getString(android.R.string.ofc);
To reference a system resource from another compiled resource, such as a layout file, use the following format: @android:[resource type]/[resource name]
For example, you could use the system string for ok by setting the appropriate string attribute as follows:
Was this article helpful?