Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How big can strings.xml resources be?

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?

like image 644
Thelouras Avatar asked Dec 23 '18 10:12

Thelouras


People also ask

Why do we store strings as resources in xml?

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.

What is strings xml?

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.

What is a resource string?

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.

How do I make a string bold in xml?

Just use getText(R. string.


2 Answers

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.

like image 113
shingo Avatar answered Oct 18 '22 10:10

shingo


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.

like image 28
Hansfritzi Avatar answered Oct 18 '22 11:10

Hansfritzi