-2

I have some very long short[], some multidimensional, which I want to store in some file in my Android App. At first I tried to store these arrays in a Java Class, but it returned a "code too large" error.

Therefore I now have to find a new file format to store these arrays in (pre compile), where the values can be stored as shorts to save space.

Which file format do you recommend, and how would I go about reading from it, from my application?

anonymos
  • 167
  • 2
  • 14

1 Answers1

0

1) If it's some repeated data - use sqlite http://developer.android.com/training/basics/data-storage/databases.html

2) if you still prefer file use DataOutputStream http://developer.android.com/reference/java/io/DataOutputStream.html

3) You can serialize array and save it to a file How do I serialize an object and save it to a file in Android?

Community
  • 1
  • 1
Vovka
  • 599
  • 3
  • 10
  • That second one seems interesting, but how do I co about writing this data pre compile? – anonymos Sep 30 '15 at 12:06
  • 1
    Use temp util java program to prepare and write the data to file. Then load it on startup at your app. – Vovka Sep 30 '15 at 12:19
  • Ok, so I can write a program i normal (non-android) java using DataOutputStream to write the data to a file, and then put that in file in my res/raw folder in my android project, and read it with DataInputStream? – anonymos Sep 30 '15 at 12:24
  • Seems like a fine solution, testing it out with this example:http://stackoverflow.com/questions/26072482/write-int-to-file-using-dataoutputstreamhttp://stackoverflow.com/questions/26072482/write-int-to-file-using-dataoutputstream – anonymos Sep 30 '15 at 12:38