Android Question error from an array of 4000 strings

wwregistry

Member
Licensed User
Longtime User
i have a large array of strings (4000+)
i am getting this error:
java:6: error: too many constants

is there a maximum size for arrays in b4a?
 

wwregistry

Member
Licensed User
Longtime User
here is the error

Parsing code. 1.59
Compiling code. 2.54
Compiling layouts code. 0.23
Generating R file. 0.31
Compiling debugger engine code. Error
javac 1.7.0_25
shell\src\com\HRGincSoftware\David_Gray_SocSec\datad_subs_0.java:6: error: too many constants
public class datad_subs_0 {
^
1 error
 
Upvote 0

wwregistry

Member
Licensed User
Longtime User
i could put the data in an external file and the read the file item into the array?
but how would include the file in the program apk package.
or maybe the MAP would somehow solve this? But i would still have to include the file?
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
The issue is the code is to large for the IDE editor. It gives the same error in B4J. I put the complete array in just one sub and it started to compile and about 2 seconds in, it gave the error: Code To Large. This is not a limit of Java or B4A but may be a limit to the IDE or compiler. You will have to read it in from a file. Place the file with this data in the project folder in the Files folder. Then you can get the data with:

B4X:
Dim MyList As List
MyList = File.ReadList(File.DirAssets, "yourfilename.txt")
 
Upvote 0

wwregistry

Member
Licensed User
Longtime User
oh i get it -- the Files folder is incorporated into the apk

thanks guy's/margret this will be soooo easy :)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
In your project folder
c:\path_to_project\
You will find a folder FILES
Put the file into this folder and then compile your project... See this example. It has your data in a file in files folder and load the data to a listview. ALL 38000 lines...
 

Attachments

  • xxx2.zip
    212.3 KB · Views: 177
Upvote 0
Top