我正在尝试在我的3个应用程序之间共享数据库。目前使用内容提供程序存在一些实际困难,因此我使用android:sharedUserId,以便我可以在我的3个应用程序之间共享数据库:
我在第3个应用程序中遇到以下异常,当我尝试调试时,日志没有打印出来。我已经清理了项目,删除了APK并尝试过,但仍然没有运气。以下是我得到的例外:
06-10 20:23:57.618: D/dalvikvm(279): GC_FOR_ALLOC freed 5K, 23% free 19751K/25543K, paused 36ms
06-10 20:23:57.618: I/ActivityManager(279): app/com.android.launcher[RESUMED] app.idle/true ...resumeTopActivityLocked
06-10 20:23:57.642: I/WindowManager(279): createSurface Window{41a45bb0 com.android.launcher/com.android.launcher2.Launcher paused=false}: DRAW NOW PENDING
06-10 20:23:57.657: D/dalvikvm(876): GC_CONCURRENT freed 499K, 25% free 31358K/41671K, paused 2ms+4ms
06-10 20:23:58.204: D/OpenGLRenderer(2729): Flushing caches (mode 0)
06-10 20:23:58.728: D/OpenGLRenderer(2729): Flushing caches (mode 1)
06-10 20:23:58.728: I/ActivityManager(279): No longer want com.android.contacts (pid 2433): hidden #16
06-10 20:23:58.743: I/ActivityManager(279): removeActivityFromHistoryLocked, call sendFinishPackageName.
06-10 20:24:02.962: W/audio_hw_primary(136): select_output_device e=0, h=0, s=2, b=0
06-10 20:24:03.095: I/ActivityManager(279): app/com.example.dockbar[INITIAL] app.idle/false
06-10 20:24:03.095: I/ActivityManager(279): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.dockbar/.MainActivity} from pid 876
06-10 20:24:03.204: D/dalvikvm(279): GC_FOR_ALLOC freed 295K, 24% free 19549K/25543K, paused 60ms
06-10 20:24:03.204: I/WindowManager(279): createSurface Window{41b93940 Starting com.example.dockbar paused=false}: DRAW NOW PENDING
06-10 20:24:03.212: I/ActivityManager(279): app/com.example.dockbar[RESUMED] app.idle/false ...realStartActivityLocked
06-10 20:24:03.235: W/System.err(2729): java.lang.SecurityException: Requesting code from com.nykkos.personalize (with uid 10096) to be run in process com.example.dockbar (with uid 10097)
06-10 20:24:03.235: W/System.err(2729): at android.app.ActivityThread.getPackageInfo(ActivityThread.java:1584)
06-10 20:24:03.235: W/System.err(2729): at android.app.ActivityThread.getPackageInfo(ActivityThread.java:1561)
06-10 20:24:03.235: W/System.err(2729): at android.app.ContextImpl.createPackageContext(ContextImpl.java:1455)
06-10 20:24:03.235: W/System.err(2729): at android.content.ContextWrapper.createPackageContext(ContextWrapper.java:483)
06-10 20:24:03.243: W/System.err(2729): at com.example.dockbar.MainActivity.onCreate(MainActivity.java:45)
06-10 20:24:03.243: W/System.err(2729): at android.app.Activity.performCreate(Activity.java:4465)
06-10 20:24:03.243: W/System.err(2729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-10 20:24:03.243: W/System.err(2729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
06-10 20:24:03.243: W/System.err(2729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)
06-10 20:24:03.243: W/System.err(2729): at android.app.ActivityThread.access$600(ActivityThread.java:125)
06-10 20:24:03.251: W/System.err(2729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1149)
06-10 20:24:03.251: W/System.err(2729): at android.os.Handler.dispatchMessage(Handler.java:99)
06-10 20:24:03.251: W/System.err(2729): at android.os.Looper.loop(Looper.java:137)
06-10 20:24:03.251: W/System.err(2729): at android.app.ActivityThread.main(ActivityThread.java:4368)
06-10 20:24:03.251: W/System.err(2729): at java.lang.reflect.Method.invokeNative(Native Method)
06-10 20:24:03.251: W/System.err(2729): at java.lang.reflect.Method.invoke(Method.java:511)
06-10 20:24:03.251: W/System.err(2729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-10 20:24:03.251: W/System.err(2729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-10 20:24:03.259: W/System.err(2729): at dalvik.system.NativeStart.main(Native Method)
06-10 20:24:03.267: I/WindowManager(279): createSurface Window{41c59720 com.example.dockbar/com.example.dockbar.MainActivity paused=false}: DRAW NOW PENDING
06-10 20:24:03.360: D/OpenGLRenderer(876): Flushing caches (mode 1)
06-10 20:24:03.392: D/OpenGLRenderer(876): Flushing caches (mode 0)
06-10 20:24:03.556: W/InputManagerService(279): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41fb7ee8 (uid=10050 pid=876)
06-10 20:24:03.931: I/ActivityManager(279): Displayed com.example.dockbar/.MainActivity: +723ms
06-10 20:24:12.681: D/shpowd(252): pcb_thermal_governor(40)
06-10 20:24:12.681: D/shpowd(252): pcb_thermal_governor(40) lock
06-10 20:24:12.681: D/shpowd(252): sh_check_limittemp(40) [53] 0 , 0
06-10 20:24:12.681: D/shpowd(252): sh_check_limittemp(40) [55] 0 , 0
06-10 20:24:12.681: D/shpowd(252): pcb_thermal_governor(40) unlock
我想知道为什么它在一个应用程序中起作用而在另一个应用程序中不起作用。由于这个原因,应用程序不会崩溃,但我仍然认为,除了设置布局之外,由于此异常,活动类中没有任何反应。以下是我的创造:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//code to make connectivty with shared db.
Context sharedContext = null;
try {
// change package name if required
sharedContext = this.createPackageContext("com.nykkos.personalize", Context.CONTEXT_INCLUDE_CODE);
if (sharedContext == null) {
return;
}
} catch (Exception e) {
e.printStackTrace();
return;
}
SQLiteDBHelper dbHelper=new SQLiteDBHelper(sharedContext);
try {
dbHelper.createDataBase();
dbHelper.openDataBase();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Before db call in dockbar");
appList=dbHelper.getList();
在上面的代码中,布局已设置,但不打印Systeem.out.println。
有人可以指导我如何解决此问题