There are both some advantages and disadvantages ( I should say advantages and less advantages) in these two cases.
as in the comments of your question they said it all. I just want to add some minor points.
Localization:
For localization issue definitely String resource is the best as you can use different language file for differente Locale.
Memory:
As String resources are saved in xml file so there are some extra overhead (not a major one though)
Performance:
reading from memory is always faster than reading from file. Although in this case the performance difference is not significant
Maintainance:
It is just a personal opinion. To me maintaining res file is easier than maintaining string in class. string.xml is more readable to me.
Finally:
So my suggestion is
use string resources for the texts which will be displayed to user.
and
use static constants for internal puposes of your program like database names, internal variable, intent filter name etc.
.
stackoverflow.comm
No comments:
Post a Comment