Firstable I'm sorry for my poor english. I'm developing an application in java for android, using libgdx. I want to write on a file to save some of the applications objects, and I'm using a ObjectOutputStream to do that. Here is an extract of the code:
try {
os_savedGame = new ObjectOutputStream(new FileOutputStream("savedGame.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
os_savedGame.writeObject(obj1);
os_savedGame.writeObject(obj2);
} catch (IOException e) {
e.printStackTrace();
}
I ran it as a Desktop application and so far so good, but when I tried to run as an Android App I got the following error: Attempt to invoke virtual method 'void java.io.ObjectOutputStream.writeObject(java.lang.Object)' on a null object reference
I know that on the Desktop version, the file is stored in the android\assets folder, but I looked for the equivalent folder in my mobile phone and I couldn't find it. I searched for data/name_of_my_project in both internal and external memory and I wasn't able to find it. As previously I had a similar error, when I wasn't able to load a skin in the android version (saying that the skin doesn't exist) while I could in the desktop version, I think that my problem might be something related where the files are being stored in the android version. Can someone give me a tip on that please?
Thanks!