Home > Software design >  What is an openFileDescriptor mode?
What is an openFileDescriptor mode?

Time:10-05

Why are there fileDescriptor modes (r,w,rw) and what are they for?

   contentResolver.openFileDescriptor(uri, "w")

They are described in the documention like this:

If opening with the exclusive "r" or "w" modes, the returned ParcelFileDescriptor could be a pipe or socket pair to enable streaming of data. Opening with the "rw" mode implies a file on disk that supports seeking. If possible, always use an exclusive mode to give the underlying ContentProvider the most flexibility.

CodePudding user response:

These are nothing but modes in which you can open file descriptor.

  • "r" Read only mode. cannot be used for writing
  • "w" Write only mode. cannot be used for reading.
  • "rw" for read-and-write.
  • "rwt" for truncating or overwriting existing file contents.
  • Related