public abstract Context createPackageContext (String packageName, int flags)
Return a new Context object for the given application name. This Context is the same as what the named application gets when it is launched, containing the same resources and class loader. Each call to this method returns a new instance of a Context object; Context objects are not shared, however they share common state (Resources, ClassLoader, etc) so the Context instance itself is fairly lightweight.
Throws PackageManager.NameNotFoundException
if there is no application with the given package name.
Throws SecurityException
if the Context requested can not be loaded into the caller's process for security reasons (see CONTEXT_INCLUDE_CODE
for more information}.
Parameters
packageName | Name of the application's package. |
---|---|
flags | Option flags, one of CONTEXT_INCLUDE_CODE or CONTEXT_IGNORE_SECURITY . |
Returns
- A Context for the application.
Throws
java.lang.SecurityException | |
if there is no application with the given package name | |
PackageManager.NameNotFoundException |