How to pass binary data between two apps using Content Provider?
Posted
by
Viktor
on Stack Overflow
See other posts from Stack Overflow
or by Viktor
Published on 2011-01-06T22:22:10Z
Indexed on
2011/01/06
22:53 UTC
Read the original article
Hit count: 378
I need to pass some binary data between two android apps using Content Provider (sharedUserId is not an option).
I would prefer not to pass the data (a savegame stored as a file, small in size < 20k) as a file (ie. overriding openFile()) since this would necessitate some complicated temp-file scheme to cope with concurrency with several content provider accesses and a running game.
I would like to read the file into memory under a mutex lock and then pass the binary array in the simplest way possible. How do I do this?
It seems creating a file in memory is not a possibility due to the return type of openFile().
query() needs to return a Cursor. Using MatrixCursor is not possible since it applies toString() to all stored objects when reading it.
What do I need to do? Implement a custom Cursor? This class has 30 abstract methods. Do I read the file, put it in a SQLite db and return the cursor?
The complexity of this seemingly simple task is mindboggling.
© Stack Overflow or respective owner