One way could be to use StringTokenizer Google for the java.util.StringTokenizer java class.
Save your string array by concatenating the contents with eg: a comma to your prefs string Then read the string and use StringTokenizer to split the prefs string using the comma as the token, and load into a string array. On Jan 21, 4:20 am, Jeffrey <[email protected]> wrote: > Well, I'm needing to save potentially over 1000 values in about 12 or > so arrays. I was kind of hoping that there was an easy way to save an > array and then load it back without having to do a bunch of stuff to > it. I'm not too experienced with programming so most of my knowledge > comes from reverse engineering examples I see, and I haven't been able > to find an example on saving a populated array and re-loading it > later. > > What would be the best way to go about saving the data, since shared > preferences can't save a String[] type or an int[] type. If I mush > them all together into one item I don't know how to separate them > later. > > On Jan 19, 10:12 pm, schwiz <[email protected]> wrote:> you could use the > xmlSerializer class to write an xml file and sax to > > read it back in > > > On Jan 19, 9:23 pm, Charlie Collins <[email protected]> wrote: > > > > If your array is not too large, I agree with theSmith, using > > > SharedPreferences is very easy if you are not sure about how to use > > > other data storage approaches. If you store it as a String you could > > > then parse it and rebuild the array. > > > > If you have a lot of data, you might want to go ahead and check out > > > using a database. Here is a quick database example I wrote recently, > > > in case it helps:http://www.screaming-penguin.com/node/7742. > > > > Also, here are some examples of writing and reading to > > > files:http://unlocking-android.googlecode.com/svn/chapter5/trunk/FileStorag.... > > > See "CreateFile" for writing to a file, and "ReadFile" for reading the > > > data back. These are a bit simplified, and the process is pretty raw, > > > but the concepts are there. > > > > HTH > > > > On Jan 19, 8:25 pm, Jeffrey <[email protected]> wrote: > > > > > How do I save the contents of an array to a file and then read it > > > > again later? I have a small amount of data that will need to be stored > > > > and since I have no idea where to start on using a SQLite database, I > > > > think this will work a lot better.
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

