0

i try this code to get the string from strings.xml using variable name. It's working perfectly but i want to access string-array in xml using variable bt it's not working. Any Help would be appreciated

    String name = "app_name";
    int identifier = getResources().getIdentifier (name,"string","com.example.saa.quotes");
    if (identifier!=0){
        array=getResources().getString(identifier);
        Toast.makeText(this, array, Toast.LENGTH_SHORT).show();
    }
    else{
        array=null;//or null or whatever
        Toast.makeText(this, "Could not able to acces the Data", Toast.LENGTH_SHORT).show();
    }
3
  • Please check this link :: stackoverflow.com/questions/2453989/… Commented Oct 11, 2017 at 16:02
  • 1
    The second argument in getIdentifier() should be "array", not "string". Commented Oct 11, 2017 at 16:04
  • Thankyou it's working . Commented Oct 11, 2017 at 16:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.