ContextCompat

public class ContextCompat
extends Object

java.lang.Object
   ↳ androidx.core.content.ContextCompat


Helper for accessing features in Context.

Summary

Protected constructors

ContextCompat()

This class should not be instantiated, but the constructor must be visible for the class to be extended (ex.

Public methods

static int checkSelfPermission(Context context, String permission)

Determine whether you have been granted a particular permission.

static Context createDeviceProtectedStorageContext(Context context)

Return a new Context object for the current Context but whose storage APIs are backed by device-protected storage.

static String getAttributionTag(Context context)

Attribution can be used in complex apps to logically separate parts of the app.

static File getCodeCacheDir(Context context)

Returns the absolute path to the application specific cache directory on the filesystem designed for storing cached code.

static int getColor(Context context, int id)

Returns a color associated with a particular resource ID

Starting in Build.VERSION_CODES.M, the returned color will be styled for the specified Context's theme.

static ColorStateList getColorStateList(Context context, int id)

Returns a color state list associated with a particular resource ID.

static File getDataDir(Context context)

Returns the absolute path to the directory on the filesystem where all private files belonging to this app are stored.

static Drawable getDrawable(Context context, int id)

Returns a drawable object associated with a particular resource ID.

static File[] getExternalCacheDirs(Context context)

Returns absolute paths to application-specific directories on all external storage devices where the application can place cache files it owns.

static File[]