7

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.

3 Answers3

6

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.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
  • I like JSON Lint, thanks for the heads up on that. It is valid though! –  Nov 22 '11 at 07:28
1

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.

Varunkumar Nagarajan
  • 1,807
  • 1
  • 24
  • 43
  • Thanks guys, it is coming from a service and it works fine in a client browser based application and if I access the method directly via a URI in a browser e.g.. …articles.svc/GetArticles and in Fiddler, but it doesn’t work if the string is too long on my phone or the emulator. This how I’ve narrowed it down and thought there must be a restriction on string length in Java. I don’t think it’s a memory issue as it is only 1500 chars. Also the only HTML in the string is

    .
    –  Nov 22 '11 at 07:25
  • Also it goes through an ArrayAdapter before being put in the string! and it's crashing before it is asked to display it anywhere! –  Nov 22 '11 at 07:33
0

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.