Difference between android.app.Fragment and android.support.v4.app.Fragment

android.support.v4.app.Fragment is the Fragment class in the android support library, which is a compatibility package that allows you to use some of the newer features of Android on older versions of Android.

android.app.Fragment is the Fragment class in the native version of the Android SDK. It was introduced in Android 3 (API 11).

If you want to make your app use fragments, and want to target devices before API 11, you must use android.support.v4.app.Fragment. However, if you’re only targeting devices running API 11 or above, you can use android.app.Fragment.

Edit: the OS-contained android.app.Fragment is now deprecated (as of API level 28), and everyone should move to using the support library implementations.

Leave a Comment