Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

What Is Strings.xml???

In this tuto­r­ial you will learn about the followings–

  • What is Strings.xml and Why do we need it?
  • Where it is located in your project.?
  • How to mod­ify an exist­ing String Resource.?
  • How to add a new String Resource.?

What is Strings.xml and Why do we need it?

String.xml is a sin­gle loca­tion for var­i­ous strings your appli­ca­tion needs. here every string has a unique id, this id you use in your code to use that string. There are two ways to han­dle a string resources,

  • Resources Tab
  • strings.xml Tab

Resources Tab



String Resources

strings.xml Tab

strings.xml Tab

strings.xml Tab

Why do we need it?

Instead of pro­vid­ing the string id we can just pro­vide the actual string.

android:text=” i m a hard core text here” instead of android:text=”@string/hello_world”

then why do we do this??, you can think of a sce­nario when you have to write a same string at more than 10–20 places and if you don’t use the string id and you want to change the string value, you will have to change it at every place but if you are using string id, you need to change it at only one place.

Where it is located in your project.?

Your Project-> res -> val­ues -> string.xml


strings.xml location

strings.xml loca­tion

How to mod­ify an exist­ing String Resource?

We can mod­ify the exist­ing string resource either in Resources tab or in strings.xml tab.

First we will mod­ify using strings.xml tab

We will change android:text=”@string/hello_world” .

Hello-> res -> val­ues -> string.xml. open it.



Click on the string.xml at the left bottom.



in last two fig­ures check the “hello_world”, it’s an String id and its value is “Hello World” so if we change it we will change the text appears on the screen.

Change it to “I am Sumit Jain, say­ing Hello to the android world”

Strings.xml- change text

Strings.xml– change text

You can mod­ify it from resources tab as well, just select the string resource you want to mod­ify and change its attrib­utes, Name and Value at the right side.

How to add a new String Resource.?

Open Strings.xml from project explorer and select the Resources tab in it if already not selected, and click Add but­ton .

Strings.xml - Resources tab

Strings.xml — Resources tab

Select the String from the new win­dow and click ok.

Select String

Select String

Now you will see the new string resource added under Resources Ele­ment List. Select it, you will see the Attrib­utes for String on the right side. Enter the Name and Value in it.

Attributes For String

Attrib­utes For String

That’s it your string resource has been added.

Happy Android­ing 🙂
Sumit Jain

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *