Bagikan melalui


Context.CreateDeviceProtectedStorageContext Method

Definition

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

[Android.Runtime.Register("createDeviceProtectedStorageContext", "()Landroid/content/Context;", "GetCreateDeviceProtectedStorageContextHandler", ApiSince=24)]
public abstract Android.Content.Context? CreateDeviceProtectedStorageContext ();
[<Android.Runtime.Register("createDeviceProtectedStorageContext", "()Landroid/content/Context;", "GetCreateDeviceProtectedStorageContextHandler", ApiSince=24)>]
abstract member CreateDeviceProtectedStorageContext : unit -> Android.Content.Context

Returns

Attributes

Remarks

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

On devices with direct boot, data stored in this location is encrypted with a key tied to the physical device, and it can be accessed immediately after the device has booted successfully, both <em>before and after</em> the user has authenticated with their credentials (such as a lock pattern or PIN).

Because device-protected data is available without user authentication, you should carefully limit the data you store using this Context. For example, storing sensitive authentication tokens or passwords in the device-protected area is strongly discouraged.

If the underlying device does not have the ability to store device-protected and credential-protected data using different keys, then both storage areas will become available at the same time. They remain as two distinct storage locations on disk, and only the window of availability changes.

Each call to this method returns a new instance of a Context object; Context objects are not shared, however common state (ClassLoader, other Resources for the same configuration) may be so the Context itself can be fairly lightweight.

Java documentation for android.content.Context.createDeviceProtectedStorageContext().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to