private void save(Object o){
try {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("/sdcard/save_object.bin"))); //Select where you wish to save the file...
oos.writeObject(o);
oos.flush();
oos.close();
} catch (Exception e) {
Log.d("asd", e.getMessage());
}
}
private Object load(){
try {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("/sdcard/save_object.bin")));
Object o = ois.readObject();
return o;
} catch (Exception e) {
Log.d("asd", e.getMessage());
return null;
}
}
Dlaczego ten kod wypluwa NullPointerException?
EDIT: Prawdopodobnie brakowało permission na operacje na SDCard ;)