почему-то SharedPreferences не сохраняет значения, код находится в сервисе ...
Thread thread = new Thread() {
public void run() {
SharedPreferences sharedPref = getBaseContext().getSharedPreferences(getString(R.string.not_local_sp), MODE_PRIVATE);
long lastExecuted = sharedPref.getLong(getString(R.string.timeDone), 0L);
int scanInterval = 500 * 60 * 60;
while (true) {
if (System.currentTimeMillis() - lastExecuted >= scanInterval && contextCreator == null) {
Log.d(TAG, "inside while loop");
Log.d(TAG, String.valueOf(System.currentTimeMillis() - lastExecuted));
Log.d(TAG, String.valueOf(lastExecuted));
Log.d(TAG, String.valueOf(scanInterval));
contextCreator = new ProtectionContextCreator();
feature = AppScanFactory.createAppScan(getBaseContext());
feature.add(new BoostFeature(getBaseContext(), new StubScanStore()));
contextCreator.create(getBaseContext(), feature.getType(), NotificationService.this);
/*Shared pref*/
SharedPreferences.Editor editor = sharedPref.edit();
editor.putLong(getString(R.string.timeDone), System.currentTimeMillis());
editor.commit();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
thread.start();
переменная lastExecuted всегда получает значение по умолчанию, 0.