Skip to content Skip to sidebar Skip to footer

Why Is Using String Literals In Android Discouraged? What Other/better Alternatives Are Available?

I know that using string literals in Android is discouraged but I do not know why. I also would like to know what possible ways can get round this problem.

Solution 1:

It's not necessarily a problem, just a warning. Android encourages the use of the strings resource file where possible but you certainly can hard-code strings and have it work correctly.

See this question/answers: what's wrong with hardcoded string in android xml file?

Solution 2:

This isn't an Android-specific issue. It is a "best practice" for programming in general. It is always a good idea to put strings and other "localizable" data into separate files (properties files, resources, etc.). This makes localization into other languages much easier.

Post a Comment for "Why Is Using String Literals In Android Discouraged? What Other/better Alternatives Are Available?"