android - Preference perfomance optimization required? -
i have read preference values adapter.
sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(this); boolean value; i call following code in getview() (in adapter):
value = prefs.getboolean("key"), false); my question is: better preload value memory , use or can keep code , android itself?
when using sharedpreferences in app has multiple modifications value, it's better modify value in memory @ later point. may save sharedpreferences ..
for example, application class may have this:
public class myapplication extends multidexapplication { public static boolean flag = false; } and in getview method, doing multiple changes counter value, this:
public class brandcountriesadapter extends baseadapter { .. @override public view getview(int position, view convertview, viewgroup parent) { //.... myapplication.flag = true; //.... return convertview; } then @ time in app, might save flag value in preferences:
prefs.putboolean("key"), myapplication.flag);
Comments
Post a Comment