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

前端 未结 8 2420
臣服心动
臣服心动 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:10

    Here is simple sample from android developer.

    Basically, you can write a file in the internal storage like this :

    String FILENAME = "hello_file";
    String string = "hello world!";
    
    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
    fos.write(string.getBytes());
    fos.close();
    

提交回复
热议问题