I am getting the following error thrown from the code below. It seems to run happily on a virtual device but as soon at I run it on a real device it crashes.
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:223)
Here is the code of the function that seems to throw the error.
public void queueJump2() {
ParseQuery<ParseObject> query = ParseQuery.getQuery("settings");
query.getInBackground("BauCSafDjA", new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
String queueJumpActive = object.getString("status");
Log.i("QUEUE JUMP STATUS >>",queueJumpActive);
if (!queueJumpActive.equals("active")){
Button qjumpButton = (Button)findViewById(R.id.qjumpButton);
qjumpButton.setText("DISABLED");
} else {
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
Long dayAgoLong = (System.currentTimeMillis()/1000)-84600;
String dayAgo = dayAgoLong.toString();
Log.i("Current Time Stamp: ", ts.toString());
Log.i("dayAgo >>: ", dayAgo.toString());
Date dNow = new Date( );
SimpleDateFormat ft =
new SimpleDateFormat ("HH");
TimeZone tz = TimeZone.getTimeZone("EST");
boolean inDs = tz.inDaylightTime(new Date());
if (String.valueOf(inDs) == "false") {
You might be adding an integer to sharedpreference and trying to get it as a string. Try adding your string "status" this way.
Editor editor = sharedpreferences.edit();
editor.putString("status",string.valueof(YOUR STATUS INTEGR));
editor.commit();