Is It Possible To Stored Class's Static Object In Shared Preference?
Solution 1:
You can only save primitive data types like float, int, string, set of strings or booleans. You can serialize your objects in byte stream and then reacreate them from the byte stream, you can have a look at this Answer also this Answer
Solution 2:
You can't save a specific type object in SharedPreferences. According to the SharedPreferences.Editor interface you can only save primitive data types like: floats, ints, strings, sets of strings or booleans.
Solution 3:
You ca not directly stored class object in preference (Except inbuilt String, Boolean,integer,etc...)
But You can stored the variables from your static class in preference.
For example
When your device get switched off you have to copy all the values of static class into preference
and at the time of boot complete you can retrieve all the values from preference to your static object or at the time of re-creation of static object you can fetch the values from preferences to your static object.
Post a Comment for "Is It Possible To Stored Class's Static Object In Shared Preference?"