Is it possible to reference another string in strings.xml? [duplicate] Is it possible to reference another string in strings.xml? [duplicate] android android

Is it possible to reference another string in strings.xml? [duplicate]


You can create your own XML entities for the strings you want to use in other strings, and use them like this:

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE resources [    <!ENTITY app_name "My App">]><resources>    <string name="app_name">&app_name;</string>    <string name="welcome_message">Welcome to &app_name;</string></resources>


I don't think it's possible.What I usually do is the following:

<string name="string_one">My string</string><string name="string_two">Here it is: %s" </string>

and in the java code:

String.format(getString(R.string.string_two), getString(R.string.string_one));

I do this kind of thing for parametrize msgs like: "You have %d new mails".