Reputation: 5826
I'm trying to write some code that will reference a bool.xml file and will reference the current value inside the bool.
<bool name="enableQAurl">true</bool>
With this I want to be able to reference this in code, so that if it's set to True it does something and if false does something else. Just a simple If and else statement.
Any code references or feedback is greatly appreciated.
Upvotes: 40
Views: 31322
Reputation: 1567
The above answer of kaderud's will work perfectly. If you are not in Activity, you have to use your context.
If you are in fragment or adapter then you have to follow below.
boolean enableQAurl = context.getResources().getBoolean(R.bool.enableQAurl);
Upvotes: 5
Reputation: 5497
Resources res = getResources();
boolean enableQAurl = res.getBoolean(R.bool.enableQAurl);
Source:
http://developer.android.com/guide/topics/resources/more-resources.html
Upvotes: 84