4

I am trying to do something simple like save a file to a cache directory in Android and I am having a lot of problems. I am using Simple serializer to write out my file into xml.

Here is my code:

public void testWrite(ListDefinitions ld)
{
    Serializer serializer = new Persister();

    String fileName = "sampleExport.xml";
    try {
        File file = new File(mContext.getCacheDir(), fileName);
        file.createNewFile();
        serializer.write(ld, file);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

And I keep getting the following error:

09-18 00:35:06.229: W/System.err(4442): java.io.FileNotFoundException: /data/data/com.main/cache/sampleExport.xml: open failed: EISDIR (Is a directory)

Thank you for the help.

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
AlexIIP
  • 2,461
  • 5
  • 29
  • 44

1 Answers1

1

Probably you created directory before with wrong call. Try to clean app data in settings.

vovkab
  • 1,292
  • 11
  • 17