android-sharedpreferences

How to examine SharedPreferences from adb shell?

ε祈祈猫儿з 提交于 2019-12-02 17:16:21
Now that we can Examining sqlite3 Databases from a Remote Shell , is it possible to examine SharedPreferences from adb shell? Since it would be much more convenient to examine and manipulate SharedPreferences from command line when debugging. Or put in another way, in what files SharedPreferences are saved, and how to view and modify these files? Fine, I found the file just after I raised the question above. (It seem asking questions publicly stimulate me to search answers by myself much more diligently, since I don't want my dear peers to view me as a lazy programmer.) It is an XML file under

How to save online data with SharedPreference in Android

假装没事ソ 提交于 2019-12-02 12:58:17
I want to show 3 fragments in my Activity and load data from json in any fragments ! I need to show website data into Recyclerview with OkHTTP v3 library. I want to show this data for offline, I mean, if user turn off data/wifi show this datas for offline . but i do not want use SQLite Database ! For this idea i use SharedPreference for save data and when disable network show show to offline data from this Preference . I write below codes, but when disable network not show me datas the offline !! AsyncTask codes: public class freeDataInfo { private Context mContext; private String

PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?

风流意气都作罢 提交于 2019-11-30 07:51:39
I've implemented my own PreferenceFragment subclass (detailed here ), and want to listen for preference changes within it. PreferenceFragment provides you with two ways of doing this: getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); and getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); Which one should be used? What's the difference? I don't really understand the distinction made in the Android docs . The core difference is in their names, PreferenceManger grants access to different functionalities to the

Android preferences - what is the difference?

我与影子孤独终老i 提交于 2019-11-30 06:34:07
问题 What is the difference, when I get preferences as: PreferenceManager.getDefaultSharedPreferences(getBaseContext()); and getPreferences(Context.MODE_PRIVATE); 回答1: PreferenceManager.getDefaultSharedPreferences(getBaseContext()); Will provide an access to a preferences file that is global for the whole application package ; any activity can access the preferences (internaly, the xml file holding the preferences will be named your.application.package_preferences.xml ). contextInstance

PreferenceFragment - Difference between getPreferenceManager() and getPreferenceScreen()?

﹥>﹥吖頭↗ 提交于 2019-11-29 10:36:42
问题 I've implemented my own PreferenceFragment subclass (detailed here), and want to listen for preference changes within it. PreferenceFragment provides you with two ways of doing this: getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); and getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); Which one should be used? What's the difference? I don't really understand the distinction made in the Android docs. 回答1:

Does the presenter having knowledge of the Activity / Context a bad idea in the MVP pattern?

给你一囗甜甜゛ 提交于 2019-11-28 15:21:00
I've been playing around with the MVP pattern for a few weeks now and I've come to the point where I need context to start a service and access Shared Preferences . I've read that the purpose of MVP is to decouple the view from the logic and having context within a Presenter may defeat that purpose (correct me if I'm wrong on this). Currently, I have a LoginActivity that looks something like this: LoginActivity.java public class LoginActivity extends Activity implements ILoginView { private final String LOG_TAG = "LOGIN_ACTIVITY"; @Inject ILoginPresenter mPresenter; @Bind(R.id.edit_login

What's the difference between getDefaultSharedPreferences() and getPreferences()?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 09:59:40
I'm currently taking the "Developing Android Apps" Udacity course. In the "Lesson 3: New Activities and Intents > Use SharedPreferences" segment, the instructor asked me to dig around the Android Developer site for how to get the user preferences from SharedPreferences . However, I found it different between the official documentation and the course's solution. The Udacity course's solution says, to grab a SharedPreferences instance for the PreferenceActivity , you should call: SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); (where getActivity() is

Does the presenter having knowledge of the Activity / Context a bad idea in the MVP pattern?

柔情痞子 提交于 2019-11-26 23:53:02
问题 I've been playing around with the MVP pattern for a few weeks now and I've come to the point where I need context to start a service and access Shared Preferences . I've read that the purpose of MVP is to decouple the view from the logic and having context within a Presenter may defeat that purpose (correct me if I'm wrong on this). Currently, I have a LoginActivity that looks something like this: LoginActivity.java public class LoginActivity extends Activity implements ILoginView { private