Tuesday, January 1, 2013

Re: [android-developers] Replacement for MODE_WORLD_READABLE

Thanks Mark that's perfect. I'd always shied away from ContentProviders because they looked miles too heavy weight and complex but that is a neat and simple solution.

One question: Why the does #onCreate copy the target file?  Is it just to validate that you can read the file? Shouldn't that be done later since #onCreate is called on every App startup?

William


On Monday, December 31, 2012 8:45:57 AM UTC+10, Mark Murphy (a Commons Guy) wrote:
On Sun, Dec 30, 2012 at 5:24 PM, William Ferguson
<william....@xandar.com.au> wrote:
> So considering the use case how do I rebuild without using
> MODE_WORLD_READABLE?

Create a ContentProvider to serve the file using openFile(). Then use
a content:// Uri instead of a file:// Uri. This may reduce the number
of apps that can handle the ACTION_SEND Intent -- those that
advertised that they specifically support file:// instead of just
generically supporting the MIME type will not show up in your chooser.

Here is a sample project that packages a PDF file in an asset, unpacks
it on first run, then makes that PDF available via a ContentProvider
and views it using ACTION_SEND and your chosen PDF viewer:

https://github.com/commonsguy/cw-omnibus/tree/master/ContentProvider/Files

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

In questi siti web puoi chiedere o rispondere a domande relative allo
sviluppo di applicazioni Android: http://www.andglobe.com

--
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