The simple answer to your question is a standard that puts your entire string in a resource. There are also many reasons that if you save your line in an xml / java file, you need to update each link in that file for one line.
eg. if you want to change “Ok” to “confirm”, which are used in 5 different files, you need to change in all these 5 files, but for the String resource you just need to update one file that contains string.xml.
Edit
Below are a few reasons why we should use String.xml
1) To update a single link to multiple entries. As with @treesAreEverywhere This can be done using the public static String, but when you start the application, you will need memory before the application closes. But String written in String.xml will be loaded during use.
2) Support for multiple languages. You can create several language resources to support your multilingual application, so that the language changed using Locale will be dynamically supported by the OS at runtime according to the language folder of the resource.
3) Please check the Localization document, which will give you more information about using String.xml
4) Lines do not clutter up your application code, leaving it clear and easy to maintain.
This is a kind of coding standard, like any other language. But you can ignore it if you want, and you can create your code with an open static string variable in the code. It is not necessary to use String.xml, but its good coding practice to use it. It’s good practice, for example, to close the if block with a parentes containing only one statement, rather than leaving it as it is.
if(condition){ statement; ) if(condition){ statement; ) , not if(condition) statement;
Abhinav singh maurya
source share