Definition of Android constants

Let's define a constant

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.

Android official website

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.

String Resources

Use properly

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

Conclusion

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.

Should Android constants define resources in the values folder? Should it be defined as final static in the code? Note

This person was investigating in more detail. Thank you very much.

Other methods

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

Definition of Android constants
definition of ruby method
About the basics of Android development
Easy implementation of Android file browsing
First launch judgment of Android application
[Android] Implementation of side-scrolling ListView using RecyclerView
Basic basis of Android asynchronous processing "AsyncTask"
Preparation for Android development of POCOPHONE f1
Understand the basics of Android Audio Record
Comparison of Android Handler Looper and runOnUiThread
Thorough comparison of Android and iOS implementations
Make Log of Android Studio / Xcode convenient