String error "constant string too long"

I think the length of constant strings in java is limited to 64K -- however, you could construct a string at run time that is bigger than 64K.


Strings Longer than 64k are not allowed to be used directly in java, but you can use them indirectly.

  • Step 1) click on your string
  • Step 2) press Alt + Enter keys together
  • Step 3) Select Extract String resource
  • Step 4) Name the resource and hit enter key.

That is it. It will generate a string for you in strings.xml If you already have string in your strings.xml you can use this code to retrieve it:

String yourStr = getString(R.string.sampleBigString);

Tags:

Android