I thought that I made a Constants class and so on and tried to do public static final ...
By the way, I wondered when to use strings.xml
, so I investigated.
I thought there was some information on the official website, but I couldn't find it. .. Can you really kindly make a suggestion? OTL
By the way, there was an explanation about how to use Strings.xml, so I read it. I found out something I didn't know while using it, so I thought I should read it once.
Returning to the main topic, a survey of proper use. Although in English, I had the following question on Stack Overflow.
android - strings.xml vs static constants
Looking at the answers, I summarized them from the following four perspectives.
** Localization ** Strings.xml (for internationalization) memory Constants (defining in xml file incurs overhead) performance Constants (reading from memory is faster than reading from file) maintenance Depends on people's taste
It's not a big deal, but because of the above differences,
**-Define the character string to be displayed to the user in Strings.xml. ** ** **-Define the character string used inside the program in Constants. ** **
Was the opinion. Certainly, when you think about it, it seems natural. By the way, there was a person who had already summarized the same thing in Japanese.
This person was investigating in more detail. Thank you very much.
When I read the Android source at work, I used something like an internal path.
I think that it came to be called from a file by defining the path as com.hoge.huga.hogehoge
like the package name.
Why is this? .. .. ??
I did some research, but I couldn't find a way like this.
Let's ask when the summer vacation is over. .. ..
If anyone knows, please let me know!
Recommended Posts