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

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

This line:

final FileOutputStream outputStream = new FileOutputStream(name);

results in a FileNotFoundException with the messa

8条回答
  •  萌比男神i
    2020-11-27 06:12

    try using the permission of WRITE_EXTERNAL_STORAGE You should use that whether there is an external card or not.

    This works well for me:

    path = Environment.getExternalStoragePublicDirectory(
                    Environment.DIRECTORY_MOVIES);
    File file = new File(path, "/" + fname);
    

    and places my files in the appropriate folder

提交回复
热议问题