The maximum length of a string variable in Android

It seems that the maximum length depends on the number of characters the string can contain. In my case, it is populated with HTML via JSON and about 1,500 characters, it crashes.

The text does not highlight special characters other than HTML.

Is there a way around this or not?

Greetings

Mike.

+6
source share
3 answers

The maximum (both practical and theoretical) is much higher. Theoretically, this is 2 ^ 31 - 1 characters. In practice, you will be limited by available memory, but even in a mobile system you will have more than 1.5 KB.

You have another problem. Use JSON Lint to first verify that you have valid JSON.

+4
source

This is the same as Java. If I understand your question correctly, you are trying to read HTML data (like JSON) from the service and crash after receiving a specific answer. If so, try if the same operation works from your browser or through a simple HTML form.

+1
source

Elsewhere, size restrictions are mentioned for the contents of the ArrayAdapter. This may be your problem, not XML or Java strings in general.

0
source

Source: https://habr.com/ru/post/902081/


All Articles