Maybe stupid question but I am developing for android 2.2 to 4.1. Can I use this functionality http://developer.android.com/reference/android/preference/PreferenceFragment.html which is available only from API 11?
or must I use old http://developer.android.com/reference/android/preference/PreferenceActivity.html which has some deprecated methods.
Will old API works well on android 4.1?
PreferenceFragment will not work on 2.2 and 2.3 (only API level 11 and above). But above versions can use the older one. So you could just go with the old PreferenceActivity – deprected methods just mean that they should be avoided, but they usually still works.
CommonsWare have before wrote, that to offer the best experience for the user and still support version 2.2, you should implement two PreferenceActivity classes and then decide at runtime which one to invoke. This can be done by checking
Build.VERSION.SDK_INTand compare against ’11’.See the accepted answer here for implementation:
PreferenceActivity Android 4.0 and earlier