How to reference Android 'assets' across packages?

好久不见. 提交于 2019-12-03 03:13:22

Since Andrew White didn't explain how to do what he recommends against, I'll show you:

Context otherContext = context.createPackageContext("other.package.name", 0);
AssetManager am = otherContext.getAssets();

That doesn't seem so bad. And I've verified that there's no need for the two packages to share a user ID.

As a developer that has both pro and free versions out there I can say from experience, don't try to share assets across applications. Even if you get it to work, you'll end up with more hassle than it's worth.

If you absolutely must do this, each app must share the same system user and you must create a context in one app that mimics the other. These aren't hard to do but and can be a maintenance nightmare.

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