what's wrong with hardcoded string in android xml file? what's wrong with hardcoded string in android xml file? xml xml

what's wrong with hardcoded string in android xml file?


When you use hard coded strings in both you java code and xml file your application directly writes these strings on RAM. But when you declare them as string resources it will not be written on RAM when application launches but they are written on RAM when application needs to use them. You can declare one billion strings in resources and you can still have a light weight RAM friendly Android application.


There will not be any trouble with that. But using string.xml to put text in your app is considered as a good programming practice. Because suppose you want to the same text in more than one places in your app. It will be difficult to put the text every time hard coded, especially if the text is somewhat large. Putting the text to a single file means that you have access to the same text from anywhere in you app.


Your company was just bought out and now you get to read over thousands of lines of code and changer the old name to the new because somebody hard coded strings. You want to internationalize your code so it speaks Spanish easy.just make a new strings.xml only name it strings_es.xml the phone itself is set Spanish of course you would ttranslate but you are done.I can't read the strings cause this phone is so tiny, maybe you could give short descriptions for small phones. Read up on mvc good luck