Gubatron wrote: > I'll make it get the SharedPreferences then with a method everytime > then, I had it like that before but > I had the impression after reading the "Designing for Performance" > document on the dev guide > that it was better to use static references than calling virtual > methods (on android).
I suspect that you misread what that article wrote: "If you don't need to access an object's fields, make your method static. It can be called faster, because it doesn't require a virtual method table indirection. It's also good practice, because you can tell from the method signature that calling the method can't alter the object's state." This is comparing static *methods* to regular methods, not static *data members* to "virtual methods". Also, PrefUtils' own code reduces your application performance more than you would save from static members. Committing changes after every preference change means doing a file I/O after every preference change. In some cases, you might truly be only modifying a single preference at a time, though in that case it is unclear what code savings you get from PrefUtils. And, if you are modifying several preferences at one time, multiple file I/O operations will be rather expensive. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.

