I am using AWS Cognito, and am running into an issue with maintaining a necessary "continuation" object for resetting password between potential app closes. I would like to store the continuation object to sharedPrefs or SQLite using serialization and de-serialization. The continuation object is non-serializable. Is it possible to still serialize it? Here is my attempt
String serializedObject = "";
// serialize the object
try {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(bo);
so.writeObject(continuation);
so.flush();
serializedObject = bo.toString();
} catch (Exception e) {
System.out.println(e);
}
sharedPref.setPref("Test", serializedObject);
// deserialize the object
try {
byte b[] = json.getBytes();
ByteArrayInputStream bi = new ByteArrayInputStream(b);
ObjectInputStream si = new ObjectInputStream(bi);
ForgotPasswordContinuation obj = (ForgotPasswordContinuation) si.readObject();
} catch (Exception e) {
System.out.println(e);
}
I am receiving the following error:
java.io.NotSerializableException: com.amazonaws.mobileconnectors.cognitoidentityprovider.continuations.ForgotPasswordContinuation
Is this even possible to do? Thanks in advance.