I use the getString()
to become String from string.xml.
In my class (non-activity) does not work:
How do I get the String to this class?
public class myClass{
public String[] myInfo(String ID) {
String myString = getRessources().getString(R.string.myString);
};
}
You have to call context.getResources().getString()
, but you have to pass in a context in order to do that.
You can create a constructor, that takes that parameter for example:
Context context;
public myClass(Context context) {
this.context = context;
}