getExternalCacheDir() returns null after clearing data

前端 未结 3 1343
忘了有多久
忘了有多久 2021-02-07 04:45

I have a simple app that access and writes data to external storage. Everything works fine until I go to Settings -> Apps -> App Info and clear data via \"Clear data\" button, t

3条回答
  •  别跟我提以往
    2021-02-07 04:53

    If you use getExternal*Cache*Dir(), it is in order to store TEMPORALY data that can be cleaned by the system. If other applications in front on the backstack needs resources, the systeme can clean your data because system need resources. if you want save your data persistently, use : File file = getExternalFilesDir(null); this is an external memory for storage persitent data (like a virtual sdcard).

提交回复
热议问题