This isn't exactly the answer using shared preferences but thought it may help 
Serialize an object and pass it around :
I use the code below and then write a class that will have any variables rather than shared preferences that is not dependable.
public class SharedVariables {
public static <S extends Serializable> void writeObject(
        final Context context, String key, S serializableObject) {
    ObjectOutputStream objectOut = null;
    try {
        FileOutputStream fileOut = context.getApplicationContext().openFileOutput(key, Activity.MODE_PRIVATE);
        objectOut = new ObjectOutputStream(fileOut);
        objectOut.writeObject(serializableObject);
        fileOut.getFD().sync();
    } catch (IOException e) {
        Log.e("SharedVariable", e.getMessage(), e);
    } finally {
        if (objectOut != null) {
            try {
                objectOut.close();
            } catch (IOException e) {
                Log.e("SharedVariable", e.getMessage(), e);
            }
        }
    }
}
public static <S extends Serializable> S readObject(
        final Context context, String key, Class<S> serializableClass) {
    ObjectInputStream objectIn = null;
    try {
        FileInputStream fileIn = context.getApplicationContext().openFileInput(key);
        objectIn = new ObjectInputStream(fileIn);
        final Object object = objectIn.readObject();
        return serializableClass.cast(object);
    } catch (IOException e) {
        Log.e("SharedVariable", e.getMessage(), e);
    } catch (ClassNotFoundException e) {
        Log.e("SharedVariable", e.getMessage(), e);
    } finally {
        if (objectIn != null) {
            try {
                objectIn.close();
            } catch (IOException e) {
                Log.e("SharedVariable", e.getMessage(), e);
            }
        }
    }
    return null;
}}
Then example class:
public class Timestamps implements Serializable {
private float timestampServer;
public float getTimestampServer() {
    return timestampServer;
}
public void setTimestampServer(float timestampServer) {
    this.timestampServer = timestampServer;
}
}
Then in activity:
SharedVariables.writeObject(getApplicationContext(), "Timestamps", timestampsData);