Sto tentando di accedere alle preferenze condivise da un servizio. Ho usato il seguente per salvare il valore del testo in una stringa ...get SharedPreferences da un servizio
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("Ignore1_value", Example.getText().toString());
editor.commit();
Ma, come potrei ottenere il valore in un servizio? Tutto ciò che ho provato ritorna come nulla. Qualsiasi aiuto sarebbe perfetto e molto apprezzato?
Ho esaminato anche altre domande senza soluzione. Ho inventato questo, ma come ho detto, lo restituisce come nessun testo.
Context ctx = getApplicationContext();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
String example1string = sharedPreferences.getString("Ignore1_value","");
Log.i("**GetSettings", example1string);
prova 'SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences (youActivity.this);' quando si sta salvando il valore .. –