realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

[Feature request] Write Realm copy to OutputStream #6974

Open lukaspieper opened 4 years ago

lukaspieper commented 4 years ago

Describe your problem or use case

I want to allow the user to create a backup of the Realm database. This is already perfectly possible with writeCopyTo() and writeEncryptedCopyTo(). Due to the new file access limitations in Android 10/11 I am forced to use the Storage Access Framework (SAF). Because of this I cannot provide an instance of java.io.File but a java.io.OutputStream.

Describe the solution you'd like

I would like to have an overload of writeCopyTo() and writeEncryptedCopyTo() that takes java.io.OutputStream as parameter.

Additional context

To be fair, it is currently possible to work around this issue by creating a copy in internal storage with the existing methods, and to move this copy to external storage via InputStream and OutputStream. But this adds a lot of overhead.

cmelchior commented 4 years ago

Yes, the new changes to Storage Access is a bit annoying. It does seem to make sense to expose an OutputStream if possible.