Skip to content Skip to sidebar Skip to footer

How To Reference Android 'assets' Across Packages?

I have an Android App that is published in a 'free' and 'pro' version. I have set up my project with a base 'library' project that is referenced from both versions, such that my pa

Solution 1:

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

ContextotherContext= context.createPackageContext("other.package.name", 0);
AssetManageram= 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.

Solution 2:

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.

Post a Comment for "How To Reference Android 'assets' Across Packages?"