About
String is a resource
Articles Related
Location
Located in /res/values/strings.xml
Formatting
Bad practice:
textView.setText(variable + " unitSymbol");
Good practice:
<!-- import the xliff namespace in the strings.xml -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Format it -->
<string name="welcome">
Hi <xliff:g id="name">%1$s</xliff:g>
You have <xliff:g id="count">%2$d</xliff:g> new messages
</string>
- Context.getString. From the context, you can get access to the string XML declaration.
String s = context.getString(R.string.welcome,myNameVariable, myCountVariable);
Localization
Example
<resources>
<string name="app_name">Sunshine</string>
<string name="action_settings">Settings</string>
<string name="refresh">Refresh</string>
</resources>