Android: Using Switch Preference pre API level 14

android, preferences

Solution

If I use preferences.xml to create my preference screen is there some way to distinguish between the API levels? So having a check box for old releases and a switch for API 14?

Create a `res/xml-v14/` directory that contains a `preferences.xml` that has your `SwitchPreference`. Create a `res/xml/` directory that contains a `preferences.xml` file that replaces the `SwitchPreference` with a `CheckBoxPreference`. Android will load the right `preferences.xml` file edition based on the device version the app is running on.

Problem

Pre-API Level 14 there is no switch preference. If I use preferences.xml to create my preference screen is there some way to distinguish between the API levels? So having a check box for old releases and a switch for API 14? What would be the best way?

Original source