خرید بک لینک

Vote count: 0

I'm trying to change a TextView and I want it to be permanent, so I'm using SharedPreferences. Sadly, something is wrong, because the TextView doesn't update.

MainService:

private void updateUI(Intent intent) {
    String counter = intent.getStringExtra("counter");
    TextView txtCounter = (TextView) findViewById(R.id.txtCounter);
    assert txtCounter != null;

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(String.valueOf(txtCounter), counter);
    editor.commit();
}

asked 47 secs ago

برچسب: sharedpreferences not working,sharedpreferences not working across activities,sharedpreferences not saving,sharedpreferences not saving values,sharedpreferences commit not working,sharedpreferences clear not working,android sharedpreferences commit not working,android sharedpreferences remove not working, نویسنده: استخدام کار تاريخ: سه شنبه 26 مرداد 1395 ساعت: 0:11

صفحه بندی