String Resources

Lakeisha McCree
1 min readMay 5, 2021

I continued building a Note app this past week in a new language (for me), Kotlin. As I stated before, Kotlin s a language that combines object-oriented and functional programming, which basically means that it uses programming objects that are reusable.

While coding in and learning Android Studio, I came across a resource for strings, called a string resource. A string resource provides text strings for your application with optional text styling and formatting. It first appears as a warning, that a hardcoded string has been detected in your app code. Having a hardcoded string means the app will be harder to translate into other languages and it is harder to reuse strings in different parts of you app.

To fix this, Android Studio provides a simple solution. If you click on the warning triangle in the component tree, the full message should open. At the bottom of the message, a Suggested Fix is given, and all you have to do is click the Fix button. This prompts the Extract Resource dialog box to open. To extract a string means to take text and create a string resource in strings.xml. This will change the text attribute for the given resource to @string/nameOfResource.

--

--