By : Ketan Bhimani
138
Using Boolean Resources Programmatically
To use a Boolean resource,you must load it using the Resource
class.The following code accesses your application’s Boolean
resource named bAdvancedFeaturesEnabled.
boolean bAdvancedMode =
getResources().getBoolean(R.bool.bAdvancedFeaturesEnabled);
Working with Integer Resources
In addition to strings and Boolean values, you can also store
integers as resources.Integer resources are defined in XML under
the /res/values project directory and compiled into the application
package at build time.
Defining Integer Resources in XML
Integer values are appropriately tagged with the <integer> tag and
represent a name value pair. The name attribute is how you refer
to the specific integer programmatically, so name these resources
wisely.
Here’s an example of the integer resource file
/res/values/nums.xml:
<?xml version=”1.0” encoding=”utf-8”?>
Using Integer Resources Programmatically
To use the integer resource, you must load it using the Resource
class. The following code accesses your application’s integer
resource named numTimesToRepeat: