I'm trying to save a map into a file but I'm getting java.io.NotSerializableException
. I know this means that I have to implement Serializable to the class. The problem is that It's throwing the error even with Serializable implemented.
Code for storing:
private void storePoints(Map<String,WifiPoint> list) throws IOException{
// store in file
FileOutputStream fos = context.openFileOutput("points", Context.MODE_PRIVATE);
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(list);
os.close();
}
Wifipoint:
public class WifiPoint implements Serializable{
private static final long serialVersionUID = 2;
public String ssid;
public String bssid;
public String capabilities;
public double latitude;
public double longitude;
public int level;
}
UPDATE: The real fix was: I needed to declare the WifiPoint in a separate file insted of declaring it inside another class.
Sorry, I didn't put the codes properly for anybody to get the correct answer