How to write data on android

I’m not able to copy data on android (at least on AVD, not yet tried real device):

for (filename in assetManager.list("")) {   // e.g. TestA.png found
  var `in`: InputStream = assetManager.open(filename)
  var out: OutputStream = FileOutputStream(File(getExternalFilesDir(null), filename))
  `in`.copyTo(out)  // fails due to R/O-System
  ...

throws:

java.io.FileNotFoundException: TestA.png: open failed: EROFS (Read-only file system)

Though TestA.png can be found and read
and WRITE_EXTERNAL_STORAGE permission is granted.

What am I doing wrong?

Other errors might be related and are:

E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
E/Vold: Failed to find mounted volume for /storage/sdcard/Android/data/com.tye.Capalyser/files/

This question doesn’t seem to be related to Kotlin. For general Android development questions, please use StackOverflow or another forum.

1 Like