简体   繁体   中英

Max length of a string variable in Android

There seems to be a max length to how many chars a string can hold. In my case it's being populated with HTML via JSON and at around 1500 chars it crashes.

There are no special characters in the text apart from HTML.

Is there a way around this or is that it?

Cheers,

Mike.

The maximums (both practical and theoretical) are far higher. Theoretically, it's 2^31 - 1 characters. In practice, you'll be limited to available memory, but even on a mobile system you'll have more than 1.5KB.

You have a different issue. Use JSON Lint to first check that you have valid JSON.

Its the same as what Java offers. If I understand your question correctly, you are trying to read HTML data (as JSON) from a service and it is crashing after receiving certain response. If that is the case, try if the same operation works from your browser or through simple HTML form.

Elsewhere in Stack Overflow there are mentions of a size limit on ArrayAdapter content. This may be your problem, not XML or Java strings in general.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM