Open lukaspieper opened 3 years ago
Hi @lukaspieper
Yes, it is fine to crosspost here. You are correct, we might as well add these overloads from the beginning when implementing the APi's for Kotlin. They have just not been prioritized for Java since, as you mention, a workaround do exist.
@lukaspieper @cmelchior on Android 11, I would like to using writeCopyTo() to create a backup file (.realm) then immediately share the file (via Intent) to let user share this file via other apps (Whatsapp, Gmail, Telegram...). Can you please give me an example code in this case?
I hope it's OK to cross-post my issue here. I thought it might be easier to consider it here, since this is still an early stage of development.
I saw in PR #116 that there is a class
RealmFile
, maybe that would be a good starting point. From my point of view, however, the class should not be path-based, but have some kind of (read
and)write
methods that can then be implemented under Android via stream.I think the SAF issue will get even more attention once developers are forced to raise the target SDK accordingly.
Original issue text (realm-java)
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()
andwriteEncryptedCopyTo()
. 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 ofjava.io.File
but ajava.io.OutputStream
.Describe the solution you'd like
I would like to have an overload of
writeCopyTo()
andwriteEncryptedCopyTo()
that takesjava.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.