I want my app to have unique ID combined from integer number and iteration of it, also i want to make it unique every time it starts.
For example
If it first time start with zer,increment it after just before finish, and start with new walue, in this example 1.
I'm trying to make it via sharedPrefs but the checking Toast show the same value (0) why is that?
Here is my code :
public final String SHARED_PREFS_NAME = "dowolna";
private SharedPreferences prefs;
static int valueYouWant;
onCreate(...) {
.
.
.
prefs = getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE);
valueYouWant = prefs.getInt("lol", 0);
Toast.makeText(getApplicationContext(), String.valueOf(valueYouWant), Toast.LENGTH_SHORT).show();
.
.
.
}
and then
@Override
protected void onDestroy() {
super.onDestroy();
SharedPreferences.Editor edit = prefs.edit();
edit.putInt("lol", valueYouWant++);
edit.commit();
}