Question

I use SimpleXml to write XML file to internal storage in Android device. The file is created in data/data/package_name/file_name.xml, but the size is 0 KB. Here is my code:

Room newroom = new Room();
newroom.setRid(String.valueOf(numRoom));
newroom.setRname(roomName);

// serialize to XML using SimpleXML framework
Serializer serializer = new Persister();
File result = new File("/data/data/de.dcj.wifi/files", FILENAME);

try {
    serializer.write(newroom, result);
} catch (Exception e1) {
    e1.printStackTrace();
}

There's no error in the logcat. Can anyone point out where I do wrong? Thanks!

Was it helpful?

Solution

Ok, I've got the answer myself! Apparently, you have to initialize all the fields in the object you want to serialize ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top