My app has multiple language support and I need to enter a string value to a database. Due to some later fetching of database entries I need to compare some user selected strings regardless of language to enter them in a database.
The user selects a radio button and I retrieve the selected value with
final String userSelection =
((RadioButton) findViewById(rb.getCheckedRadioButtonId())).getText().toString();
which by my understanding should get the string in the language that is selected (lets say Italian and English which would be Gamba or Leg). in my database i need to have 'leg' entered regardless of the language.
i tried to make a method like this:
public String mapLanguage (String part){
if (part.equals(getString(R.string.leg))) return "leg";
else if (part.equals(getString(R.string.head))) return "head";
else if (part.equals(getString(R.string.arm))) return "arm";
else return "back";
}
this method is part of a class that doesnt have any vies associated with it
public class Part extends AppCompatActivity
this method is called from the constructors and setter:
this.part = mapLanguage(part);
error i have refers to the MapLanguage method:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference