问题与共享preferences在奇巧版本的android [英] Issue with Sharedpreferences in kitkat version in android
问题描述
喜在我的应用程序,我接受通code,从用户并将其存储在共享preferences。而且,我已经提供了通code开/关功能。如果用户选中时,应用程序会要求用户每次都输入通code在推出的时间,将关闭在检查关按钮。
Hi in my application I am accepting pass code from user and storing it in shared preferences. And, I have provided pass code on/off functionality. If user checked on , app will ask user to enter pass code at the time of launch every time and will be off on checked of Off button.
一切工作正常在Android的ICS,杰利贝恩版本及以下。但它从来没有工作在奇巧。不幸的是,我没有奇巧的设备调试我的应用程序。 下面是我的code我使用的共享preferences: -
Everything is working fine on android's ICS, Jellybean version and below. But it never works on Kitkat. Unfortunately, I don't have a Kitkat device to debug my app. Below is the my code I am using for shared preferences:-
SharedPreferences sharedPreferences;
//sharedPreferences = getActivity().getSharedPreferences("ServerData", Context.MODE_PRIVATE);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
Editor editor = sharedPreferences.edit();
editor.putString("Passcode", Globals.str_Passcode);
editor.commit();
请问奇巧具有与共享preferences任何问题。 请告诉我如何解决呢?或者是有访问通code功能我相同的方式,以便它会在所有版本的可访问的任何其他方式。
Does kitkat has any issues related to shared preferences. Please tell me how to resolve this? Or is there any other way to access pass code functionality i same way so it will be accessible in all versions.
推荐答案
试试这个办法,希望这将帮助你解决你的问题。
SharedPreferences sharedPreferences = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("Passcode", Globals.str_Passcode);
editor.commit();
sharedPreferences.getBoolean("Passcode",false);
这篇关于问题与共享preferences在奇巧版本的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!