I am currently building an android application and decided to use the Xml implementation rather than a database to store data. I'm loading the xml file into a list at application startup and when i want to save it back i format it to xml using XmlSerializer which then outputs to a StringWriter. I then call .toString() on the StringWriter object and write that string back into a file.
I noticed however that the applications xml files grow quite rapidly and was wondering what would happen if it's length exceded the maximum string length. Is there any way to get an array of strings from StringWriter? Here's my Serializer Method.
public String articlesAsXml() {
XmlSerializer serializer = Xml.newSerializer();
StringWriter writer = new StringWriter();
try {
serializer.setOutput(writer);
serializer.startDocument("UTF-8", true);
serializer.startTag("", "articles");
for (Articles art: AllArticles){
serializer.startTag("", "art");
serializer.startTag("", "id");
serializer.text(art.Article_Id);
serializer.endTag("", "id");
serializer.startTag("", "title");
serializer.text(art.Article_Title);
serializer.endTag("", "title");
serializer.startTag("", "body");
serializer.text(art.Article_Body);
serializer.endTag("", "body");
serializer.endTag("", "art");
}
serializer.endTag("", "articles");
serializer.endDocument();
return writer.toString();
}
catch (Exception e) { return "Failed"; }
return null;
}
Thanks in advance