ANDROID: What is the main idea of ​​using strings.xml?

Can someone please explain what is the main idea of ​​using strings.xml ? I think this would be useful for multilingual support, but how can we organize it for this? Do I need this if I do not want to use multilingual support in my Android application?

+5
source share
2 answers

The idea is that it represents one place for different lines, so your code is not packed with string literals. In addition to this, you get the ability to easily localize. Organization of files for localization is described here:

http://developer.android.com/guide/topics/resources/localization.html#creating-alternatives

Do you need it if you are not localized? No. But in the end, this can make the task easier, and I would recommend using it for this reason.

+11
source

Hard coding strings are bad.

Parameterizing strings (e.g. using strings.xml) is good.

The ability to internationalize your strings (with language versions and / or language versions of strings.xml) is even better :)

PS:

To use internationalization, simply create resource subdirectories. Google will give you lots of links / examples. Herre one:

http://developer.android.com/guide/topics/resources/localization.html

* res/values/strings.xml   
  Contains English text for all the strings that the application
  uses, including text for a string named title.

* res/values-fr/strings.xml 
  Contain French text for all the strings, including title.

* res/values-ja/strings.xml
  Contain Japanese text for all the strings...

, strings.xml( colors.xml dimens.xml .. ..), .

....

+5

All Articles