I have created the local data like below code
public class LocalDataSource {
private SharedPreferences mSharedPreferences;
private static LocalDataSource sLocalRepository;
private LocalDataSource() {
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getApp());
}
public static LocalDataSource getInstance() {
if (sLocalRepository == null) {
sLocalRepository = new LocalDataSource();
}
return sLocalRepository;
}
public void saveResponse(Context ctx, String object, String key) {
mSharedPreferences.edit().putString(key, object).apply();
}
public String getResposne(String key) {
return mSharedPreferences.getString(key, "");
}
}
and then I have save the object as String in sharedpreferences like below code
@Override
public void onSuccess(LoadLookUpResponse body) {
super.onSuccess(body);
if (body.responseCode != CommonResponse.Code.SUCCESS) {
PopupErrorDialog.newInstance(body.responseMessage.header, body.responseMessage.message, body.responseMessage.btnText1, null, null, null).show(getSupportFragmentManager(), "popup_error");
} else {
mData = body.data;
LocalDataSource.getInstance().saveResponse(getApplicationContext(), mData.toString(), "data");
}
}
Now I can get this Object String will return when I call this
LocalDataSource.getInstance().getResposne("data");
Now, How can I get this as my Response object (LoadLookUpResponse.Data) to access in my specific classes ? Because, It's returning the String. But My responses are String and arrays.
Thanks in advance.