Android boolean resource not being recognized as a bool, but as an int
android, android-resources
Solution
The generated `R` fields refer to the ID of the specified boolean (or other types). You can resolve the actual value using Resources.getBoolean. E.g.:
boolean ap = context.getResources().getBoolean(R.bool.preferences_autoplay);
Problem
I am writing an `Android` app and have an issue with defining a `boolean` resource. I have a file, `bools.xml:` ``` <?xml version="1.0" encoding="utf-8"?> <resources> <bool name="preferences_autoplay">true</bool> </resources> ``` Yet when I try to use `R.bool.preferences_autoplay`, it is recognized as an `int` and not a `boolean`: And I get the error: The method `putBoolean(String, boolean)` in the type `SharedPreferences.Editor` is not applicable for the arguments `(String, int)` I can certainly make due with using an `int` if I need to, but I don't understand why it isn't recognized as a `boolean`. Any thoughts on how to use a `boolean` resource as a `boolean`?