I have a couple objects, Location, in my app stored in an ArrayList and use parcelable to move these between activities. The code for the object looks like this:
public class Location implements Parcelable{
private double latitude, longitude;
private int sensors = 1;
private boolean day;
private int cloudiness;
/*
Måste ha samma ordning som writeToParcel för att kunna återskapa objektet.
*/
public Location(Parcel in){
this.latitude = in.readDouble();
this.longitude = in.readDouble();
this.sensors = in.readInt();
}
public Location(double latitude, double longitude){
super();
this.latitude = latitude;
this.longitude = longitude;
}
public void addSensors(){
sensors++;
}
public void addSensors(int i){
sensors = sensors + i;
}
+ Some getters and setters.
Now I am in need of storing these objects more permanently. I read somewhere that I can serialize the objects and save as sharedPreferences. Do I have to implement serializeable aswell or can I do something similar with parcelable?