Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] SharedPreferences se perdendo após atualização do app

Olá Thiago, eu colei aqui apenas um trecho do código.

 SharedPreferences sharedPref = getActivity().getSharedPreferences(getString(R.string.pref_file_sessao_key), Context.MODE_PRIVATE);
 SharedPreferences.Editor editor = sharedPref.edit();
 editor.putBoolean(getString(R.string.pref_sessao_logado), true);
 editor.putInt(getString(R.string.pref_sessao_id_empresa_key), vendedor.getIdEmpresa());
 editor.putInt(getString(R.string.pref_sessao_id_filial_key), vendedor.getIdFilial());
 editor.apply();

acontece que quando atualizo o app estes valores se perdem. será que vou ter que armazenar estes valores no sqlite.

2016-08-29 9:11 GMT-03:00 Thiago Lopes Rosa <thiago.rosa@gmail.com>:
Está faltando você fazer o commit/apply...

editor.apply();

On Mon, Aug 29, 2016 at 9:09 AM, Pablo Borges <pablosborges@gmail.com> wrote:
pessoal,

eu tenho um app que salva alguns dados no  sharedpreferences.

 SharedPreferences sharedPref = getActivity().getSharedPreferences(
 getString(R.string.pref_file_sessao_key), Context.MODE_PRIVATE);
 SharedPreferences.Editor editor = sharedPref.edit();
  editor.putBoolean(getString(R.string.pref_sessao_logado), true);

acontece que em alguns tablets após atualização do aplicativo. estes valores se perdem.

existe outra maneira de resolver isto?

obrigado

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário