Android Java.lang.Long Cannot Be Cast To Java.lang.String
Okay so I am storing a long in my shared preferences using e.putLong('startTime', SystemClock.uptimeMillis()); and I am getting it from share preferences like SHARED_PREFS = cont
Solution 1:
If you were to read the docs you would read that the getLong
method will:
Throws ClassCastException if there is a preference with this name that is not a long.
So, somewhere else in the app, you must have called:
e.putLong("startTime", "someString");
Solution 2:
This is a bit late, but for those who are still facing this problem, just overwrite this value in SharedPreferences with the value in the type you need before calling the get method. Perhaps a String (or other type) was written there before
Post a Comment for "Android Java.lang.Long Cannot Be Cast To Java.lang.String"