Wednesday, November 28, 2012

[android-developers] Re: Write to another application's internal memory

I think that the fact that this question is about "writing to internal memory" is confusing people.  I think that all you want to do is allow App2 access to a file owned by App1.  That is probably pretty easy:

App1 will own the file(s).  They will be in its sandbox files directory and not visible to any other app including App2.  App1 must contain a ContentProvider that supports  android:grantUriPermissions.  When App1 wants to pass a file to App2 it will fire an intent to a service in App2, with a URI that identifies, to its own (App1's) content provider, the file it wants to share.  A Service in App2 catches the intent and makes a request for an {In, Out}putStream, for the URI, to the content provider in App1.  App1's ContentProvider.openFIle method decodes the URI and opens and returns a ParcelFileDescriptor for the file to which it corresponds. (fyi, don't try this with assets!).

Bob's your uncle.

-blake
The 2nd Edition of Programming Android is now available!:
http://shop.oreilly.com/product/0636920023005.do

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate