Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which strings to store in strings.xml?

Are there any suggestions on which strings you should store in strings.xml and which strings can be stored as String objects? For example, do I have to put a string into strings.xml, if I use it only to complete a certain action and then it can be destroyed? And what is the main reason in storing strings in xml? Thanks in advance for your answers.

like image 867
Egor Avatar asked Jul 25 '26 22:07

Egor


2 Answers

Any string that will be displayed to the user should be in strings.xml. This is useful in case you ever want to support other languages for your application. If you do, you just create a new strings.xml file that language with translated values. You can learn more about it here.

like image 80
Haphazard Avatar answered Jul 27 '26 12:07

Haphazard


One reason is multi-language support. You should store the strings that you use in Activities - TextView, button's caption and so on.

like image 25
Plamen Nikolov Avatar answered Jul 27 '26 13:07

Plamen Nikolov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!