public abstractContextcreatePackageContext(StringpackageName, 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.
ThrowsPackageManager.NameNotFoundExceptionif there is no application with the given package name.
ThrowsSecurityExceptionif the Context requested can not be loaded into the caller's process for security reasons (seeCONTEXT_INCLUDE_CODEfor more information}.
Parameters
| packageName | Name of the application's package. |
|---|---|
| flags | Option flags, one ofCONTEXT_INCLUDE_CODEorCONTEXT_IGNORE_SECURITY. |
Returns
- A Context for the application.
Throws
| java.lang.SecurityException | |
| if there is no application with the given package name | |
| PackageManager.NameNotFoundException |
本文介绍如何在一个Android应用程序中创建并编辑Preferences,并允许另一个应用程序以可读方式访问这些Preferences。示例展示了如何使用Context.MODE_WORLD_READABLE权限级别来实现跨应用的数据共享。
873

被折叠的 条评论
为什么被折叠?



