Share files between applications

空扰寡人 提交于 2019-12-30 11:06:12

问题


Can i share one application related data with another. Say I have a music file in resources/raw folder of apk2. Can I use the same file in apk1.

thx...


回答1:


If your apps are signed with the same certificate and have the same android:sharedUserId declared in the manifest, they can share data in that they can read/write to each others' data directories. They can even share a process if you'd like them to (see android:process).




回答2:


The application which has the music file will need to implement a Content Provider. This will allow the other application to retrieve the content.




回答3:


To share the files between the apks, you need to pass the uri of the files along with the implementation of Content Provider. And while accessing it back, use the content resolver in the second apk.

You can see this in Gallery and Email app integration where an image gets attached to the email from Gallery.



来源:https://stackoverflow.com/questions/2681035/share-files-between-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!