I want to save/load a BigInteger
array into/from the SharedPreferences.
How can it be done?
For example for the following array:
private BigInteger[] dataCreatedTimes = new BigInteger[20];
I want to save/load a BigInteger
array into/from the SharedPreferences.
How can it be done?
For example for the following array:
private BigInteger[] dataCreatedTimes = new BigInteger[20];
Using Gson you can convert to a json
String
and back, which then of course makes it trivial to save in preferences:To add Gson in gradle add dependency:
and here's your save preference method
Now to get back your BigInteger Values ,
Here's your loadPreference Method
Note : You can change delimiter what ever you want, but prefer to take character array. Change Delimiter length accordingly
Try this and let me know if it works
Consider
bigInts
is theBigInteger[]
you want fromPreference
: