- Home /
How to save an array of string in Android?
Hi guys,
I'm working on an Android project, how do I save an array of strings in Android ? and there is a limit to the amount of string that I can add to the array (I need to add a lot of them).
thank you, Diego.
I'm a little unsure about just what you mean by "save", but if you want to write it to playerprefs, might ArrayPrefs2 help?
If you simply want to store an array of strings as a variable, I'd recommend watching this.
On mobile systems, I believe there is no limit to the size of playerprefs, nor a limit on the number of elements that can be in an array.
Answer by Sisso · May 16, 2014 at 06:06 PM
I think that you are talking about PlayerPrefs.
You must serialize your array into a simple string, you can use json, join/split, xml, etc.
I think that have no limitation about amount of data that you save in it, only normal limitations like memory and disk space. But, it is not designed to use like this.
I recommend to directly use filesystem. Something like:
import System.IO;
var path = Application.persistentDataPath + "/data";
using (StreamWriter w = new StreamWriter(path)) {
w.WriteLine("hi");
}
using (StreamReader r = new StreamReader(path)) {
var line = r.ReadLine();
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613145206im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
PlayerPrefs for unlocking items 1 Answer
Textures are distorted when building for android 2 Answers
screenshot 0 Answers