How to extract strings into strings.xml resource files in Android Studio

I have previously posted a guide on how to extract string resources in Eclipse, so I thought I would do it for Android Studio too, as it is not directly obvious how to acheive this.

All your applications strings should be placed in the various /values/strings.xml files in your app. This is the best practice, gathers all texts, and easily enables you to translate your app into other languages.

While developing apps, it might be easier to just hardcode the string values, but when you are done testing, you can hit  ALT + Enter to bring up the string resource extraction dialog.

Choose Extract string resource and type a name for the resource in the dialog.

Your string should now have been moved to the strings.xml file you selected (default is in: values/strings.xml).

The process goes like this:

Set the cursor inside the text you want to extract (here the text is the title “Cancel”) and hit ALT + Enter  and select “Extract string resource”:


Give your resource a describing name and hit “Ok”:

Your string has now been moved to the strings.xml file.

To view it, you can hold down cmd while clicking it (here “menu_cancel”) with the mouse, this will open the strings.xml file for your.extract3

You can also extract string resources from your code, using the same method:


comments powered by Disqus