读取另一个软件包的资产文件夹文件 [英] read asset folder files of another package
问题描述
我有两个使用相同android:sharedUserId
的android应用程序
说出应用程式A和应用程序B.
I have two android applications using the same android:sharedUserId
Say Application A & Application B.
是否可以从A读取B的资产文件夹的内容?
Is there a way to read the contents of asset folder of B from A?
推荐答案
您不需要android:sharedUserId
(除非您真的知道自己在做什么,否则使用android:sharedUserId
是有风险的) .最后我检查了一下,资产是世界可读的;任何应用程序都可以读取其他应用程序的资产.
You should not need android:sharedUserId
(and unless you really know what you're doing, using android:sharedUserId
is risky). Last I checked, assets are world-readable; any app can read another app's assets.
You should be able to call createPackageContext()
to get a Context
associated with the other app, then use getAssets()
as normal to get an AssetManager
from that Context
.
这篇关于读取另一个软件包的资产文件夹文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!