0

I have some very long short[][][] which I were storing in a class in my android project, before I got a "code too large" error (when compiling my project). After some research, I realized that I maybe shouldn't store these arrays in a java class, and so, now I wonder how I should go about storing, and reading these arrays.

These arrays are so long that I can't store them as Strings (I hope there is some way to store them where they don't take up more space than short[][][]). It would also be great if I don't have to write too much code to read the files.

If you need more info, please don't hesitate to ask.

anonymos
  • 167
  • 2
  • 14
  • Where do you get the data from in the first place? (maybe you can simply read that source directly from java) – zapl Sep 29 '15 at 08:10
  • No, I don't think it's a good idea to read the source directly from my android project, because they come in a very bad format, which is quite performance-heavy to convert into arrays. – anonymos Sep 29 '15 at 08:13
  • What is "too much code"? I guess you will have to serialize this data into a file (either in a readable form or a binary one for saving file size), then deserialize it in your program. – dotvav Sep 29 '15 at 08:14
  • If you don't want to read them directly you could make a little tool that transforms the bad data into a nice binary format. Then put that data in your project and now reading gets efficient. E.g. a simple length prefixed (for each array []) format should be readable / writable with a few for loops. – zapl Sep 29 '15 at 08:18
  • @dotvav I'm new to storing data in a non-java class in a project. How do I go about storing 16-bit numbers in a res/raw file? And then reading it – anonymos Sep 29 '15 at 08:24
  • @dotvav I see now that I can simply create my own binary file, but how do I go about doing that? There is no binary option when creating a file under res/raw – anonymos Sep 29 '15 at 08:53
  • I can't answer right now but you may find useful information here http://stackoverflow.com/questions/7619058/convert-a-byte-array-to-integer-in-java-and-vise-versa – dotvav Sep 29 '15 at 10:46

0 Answers0