// TODO Der kommer en EOF exception når der forsøges at readObject. // TODO Brug sharedpref til at gemme og læse tamagotchi. private synchronized void loadTamagotchiFromFile() { FileInputStream fis = null; try { available.acquire(); Log.d(TAMAGOTCHI, "Loading the tamagotchi from: " + fileName); fis = this.openFileInput(fileName); ObjectInputStream is = new ObjectInputStream(fis); // is.reset(); // TODO Bug when reading a tama from filesystem // Steps to reproduce: Kill with the app context menu thingie, start app again. tama = (Tamagotchi) is.readObject(); if (tama == null) return; is.close(); fis.close(); initializePlayingfield(); Log.d(TAMAGOTCHI, "Done loading the tama"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (OptionalDataException e) { e.printStackTrace(); } catch (StreamCorruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { available.release(); } }