noob noob -4 years ago 230
Android Question

Random access to DocumentFile

How can I get Random Access to

DocumentFile
's
OutputStream
, so that I can seek to any particular position and start writing from there onwards. Or if there's a way of appending to the existing content of a
DocumentFile
. The file is essentially going to be on an external SD Card, thus I have to use
DocumentFile
for this purpose.

In short, is there a
RandomAccessFile
for
DocumentFile
too?

Answer Source

It doesn't actually answer the original question but was working for my requirement. I wanted to append the new data to existing DocumentFile and the method suggested by greenapps was the one which solved it for me. (Thanks to him)

I just needed to open the output stream in wa mode to append.

getContentResolver().openOutputStream(docfile.getUri(), "wa");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download