How to access string present in string.xml
android
Solution
use `getResources().getString` for getting string value from strings.xml as:
String str=getResources().getString(R.string.internetNotAvailable);
showAlert(str);
and also you are passing null to `AlertDialog.Builder` for creating AlertDialog. please pass current Activity context instead of null for creating `AlertDialog` as:
AlertDialog.Builder builder = new AlertDialog.Builder(Your_Current_Activity.this);
Problem
I want to build the alertdialog with the string present in String.xml but R.string.string1 is returning int. Please tell me the way to get the string prestent in string.xml here is my code.. ``` public static void showAlert(String alertMessage) { final AlertDialog.Builder builder = new AlertDialog.Builder(null); builder.setMessage(alertMessage); final AlertDialog alert = builder.create(); alert.show(); } showAlert(R.string.string1); ```