I saw this post that says when strings.xml
gets too big the app may crash. My strings.xml
file is 800 plus lines right now and it will be a lot bigger in a while.
The answers in the post say that using a SQLite database can prevent the crash.
But in my case I have a SQLite database that takes the data for the entries from strings.xml
because my app uses locales for different languages.
My question is, how big can strings.xml
be? And if I hit the line limit what can I do to prevent the crash?
The purpose of strings. xml (and other *. xml resource files) is to regroup similar values in one place. This facilitates finding values that would be otherwise buried in the code.
String. xml file contains all the strings which will be used frequently in Android project. String. xml file present in the values folder which is sub folder of res folder in project structure.In Android Studio, we have many Views such as TextView,Button,EditText,CheckBox,RadioButton etc.
A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.
Just use getText(R. string.
The Resources.get***
methods doesn't have any explicit limitation, so it depends on your device's memory size. And as I know the old version of Android has per process memory limitation.
There is no limitation of the strings.xml. Its more a problem of loading a string array. The getResources().getStringArray function is not meant to load arrays with more elements than 512 (more about this here Should I be using something other than getResource().getStringArray() to populate a large array?) But as long as you are not using big arrays you should be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With