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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -