Description: AndroidBugFix contains a large number of fixes for Android, Java, Kotlin, Android Studio, Xamarine, Flutter, React Native and Ionic related issues. Daily Updated!
.net (22932) ajax (1396) abi (255) adb (54) admob (33) .net-6.0 (6) access-token (2) accessibilityservice (1) actionbarsherlock (1) address-sanitizer (1)
October 03, 2022 android , android-resources No comments
In android, I want to use a string-array resource to create a public static final String in one of my classes. However, it seems I must call getResources() on a Context and I can't find any context at the class level. Is this possible?
public class DBAdapter { Resources res = getResources(); public static final String[] gradeTypes = res.getStringArray(R.array.gradeTypes); ... Solution You can't do that. If you need the Context , you can pass it with constructor: