Soru & Cevap

"getSharedPreferences" hatası ...

16.07.2014 - 05:29

Merhaba,

SharedPreferences'ı import ettiğim halde getSharedPreferences'ta "Cannot make a static reference to the non-static method getSharedPreferences(String, int) from the type " böyle bir hata alıyorum, çözemedim. Yardımcı olabilir misiniz?

 

3 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-2176-1429627808.jpg
bekirdursun
19.08.2014 - 10:18

[code]SharedPreferences sharedPreferences = getSharedPreferences("bakiye_xml",MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.putString("bakiye_veri", veri);
editor.commit();[/code]

şeklinde kullanabilirsin.

 

Eğer fragment yapısını kullanıyorsan;

[code]SharedPreferences sharedPreferences = this.getActivity().getSharedPreferences("bakiye_xml",Context.MODE_PRIVATE);[/code]

picture-399-1379511904.jpg
halil
19.08.2014 - 09:36

çözebildin mi?

picture-1372-1408467635.jpg
ahmtbrk
16.07.2014 - 06:03
PREFS degiskeni static mi? Hata sanirim bu yuzden abstract bir classta static kullanmaya calisiyorsunuz