Resource Not Found Exception in class without context or activity

3673 views android

public class EmergencyNumbersGenerator {

    private static ArrayList<EmergencyNumberFeatures> features;

    public static ArrayList<EmergencyNumberFeatures> generateEmergencyNumber()

        features = new ArrayList<>();

        EmergencyNumberFeatures em = new EmergencyNumberFeatures(


This happens to be my code and this class EmergencyNumberGenerator has no Context whatsoever. So, I looked in SO for solution to get string from strings.xml and found that I can use


But, I am getting error where it says, Resource is not found.

 android.content.res.Resources$NotFoundException: String resource ID #0x7f0d0085
    at android.content.res.Resources.getText(
    at android.content.res.Resources.getString(
    at com.utilnepal.MobileHelp.ActivitiesFragment.EmergencyFragment.onCreateView(

Any help regarding this issue?

answered question

Can you pass context in this class ?? and you can use it like that context.getResources().getString();

I could. But I preferred not to. I am looking for way around!

Use shared preferences instead

1 Answer


So, Resources.getSystem() you can use everywhere in yours code.

But with that you can get only System Resources. String, that you defined in strings.xml is not system resource.

Check this link system resources and non-system

posted this

Have an answer?


Please login first before posting an answer.