Trying to create a file in Android: open failed: EROFS (Read-only file system)

前端 未结 8 2217
臣服心动
臣服心动 2020-11-27 05:52

This line:

final FileOutputStream outputStream = new FileOutputStream(name);

results in a FileNotFoundException with the messa

相关标签:
8条回答
  • 2020-11-27 06:23

    To use internal storage for the application, you don't need permission, but you may need to use: File directory = getApplication().getCacheDir(); to get the allowed directory for the app.

    Or:
    getCashDir(); <-- should work
    context.getCashDir(); (if in a broadcast receiver)
    getDataDir(); <--Api 24

    0 讨论(0)
  • 2020-11-27 06:26

    Google have restricted write access to the external sdcard. From API 19 there is a framework called Storage Access Framework which allows you the set up "contracts" to allow write access.

    For further info:

    Android - How to use new Storage Access Framework to copy files to external sd card

    0 讨论(0)
提交回复
热议问题