Setup SharedPreferences in credential encrypted storage are not available until after user is unloc

Caused by: java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked
 08:08:00.310  5652  5652 E AndroidRuntime:        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:387)
 08:08:00.310  5652  5652 E AndroidRuntime:        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:372)
 08:08:00.310  5652  5652 E AndroidRuntime:        at android.content.ContextWrappe

https://developer.android.google.cn/  
https://source.android.google.cn/
https://developer.android.google.cn/training/articles/direct-boot

 

访问设备加密存储

要访问设备加密存储,请通过调用 Context.createDeviceProtectedStorageContext() 创建另一个 Context 实例。使用此上下文执行的所有存储 API 调用均访问设备加密存储。 以下示例访问设备加密存储并打开现有应用数据文件:

Context directBootContext = appContext.createDeviceProtectedStorageContext();
// Access appDataFilename that lives in device encrypted storage
FileInputStream inStream = directBootContext.openFileInput(appDataFilename);
// Use inStream to read content...

仅针对在“直接启动”模式下必须可访问的信息使用设备加密存储。请勿将设备加密存储用作通用加密存储。对于专有用户信息,或在“直接启动”模式下不需要的加密数据,请使用凭据加密存储。

    原文作者:空白的泡
    原文地址: https://blog.csdn.net/kongbaidepao/article/details/84032276
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞