How to transfer files between Android applications running on the same device?

前端 未结 3 1951
遇见更好的自我
遇见更好的自我 2021-01-31 17:50

I am writing an Android application that interfaces with a RESTful service. This web service essentially fronts a file system, and provides metadata as well CRUD access to the

3条回答
  •  难免孤独
    2021-01-31 18:51

    Content provider is definitely the way to go. If you consider that google uses this approach for almost everything then it becomes appaentr that this is the intended design method.

    I'm not extolling the virtues of them, but in the land of the blind, the one eyed content provider is king.

    Update

    There is an example of how to do this in CommonsWare book, see the link provided.

    Source of Content Provider/Files

    Use the synch framework for content providers. Simply maintain a list of requests and then schedule the sync to download those file. You can also do this on network tickles etc. you can use broadcast intents or contentobserver to notify clients that the file is downloaded.

    In essence this is probably similar to your 3rd option but importantly it uses the Android supplied tools rather than rolling your own.

    Ad Endum

    Best place to start is the android SDK sample in: android-sdk\samples\android-8\SampleSyncAdapter but be warned that there's a load of contacts related stuff that masks the juicy bits. It took me a while to figure out that I could delete almost all of it except the syncadapter

提交回复
热议问题