Search code examples
androidandroid-preferences

Should I use the preference class from the support library or my current API when building my app?


I'm in the processes of creating my first app and I'm working on the preference screen using this page as a reference. When I create the PreferenceFragment and go to import the class I have the option of the android.preference class from the API I'm building with (API 25) or the v14 support library which I imported in my gradle file. Here's a screenshot of the message that sparked my question:

Do I want to use the v14 support library version so my app is compatible with older devices? If I used the API level 25 version would my app only run on devices with API 25 or above?


Solution

  • PreferenceFragment was added in API level 11. You should use the support variant if you plan to support versions below 11.

    You can still use the support variant if you don't plan to support these versions, but it does not provide any benefit, and I'd expect the core version to perform slightly better.