1

I want to access the string resource from strings.xml file within same strings.xml file.

For example:

<resources>
    <string name="app_name">Kitty App</string>
    <string name="app_welcome_title">Welcome to [here i want to access 'Kitty App' string resource that is above this line]</string>
</resources>

Is this possible? Thanks!!!

1
  • 2
    AFAIK, there is no in-resource option for that, sorry. Commented Aug 1, 2019 at 17:57

1 Answer 1

-1

The answer can be found here using Entity before resource section inside strings.xml. It's not exactly that you has imagined, but it solves the question.

<?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE resources [
      <!ENTITY appname "MyAppName">
      <!ENTITY author "MrGreen">
    ]>

<resources>
    <string name="app_name">&appname;</string>
    <string name="description">The &appname; app was created by &author;</string>
</resources>

Besides, the following answer in the same reference does exactly that you think:

<string name="app_name">My App</string>
<string name="activity_title">@string/app_name</string>
<string name="message_title">@string/app_name</string>
Sign up to request clarification or add additional context in comments.

2 Comments

Kindly flag a question as duplicate instead of duplicating the post as reference.
I just do it. First, I had to discover how to mark a question as duplicate...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.