Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7413207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:39:38+00:00 2026-05-29T06:39:38+00:00

For deleting the app data i am trying to use reflection but getting NPE

  • 0

For deleting the app data i am trying to use reflection but getting NPE when invoking method

Class<?> myClass = Class.forName("android.content.pm.IPackageManager");
Method method = myClass.getMethod("clearApplicationUserData", String.class,IPackageDataObserver.class);
method.setAccessible(true);
Log.v("info",method.getName());
Object c = myClass .newInstance();
method.invoke(c,"com.example.android.apis",null);  //NPE

clearApplicationUserData return nothing and take two parameters String and IPackageDataObserver.

Am i passing the correct parameters?

Or How can i solve the problem ?

StackTrace while debugging.

 01-31 17:50:07.125: V/info(969): clearApplicationUserData
 01-31 17:50:26.305: D/dalvikvm(969): newInstance failed: p0 i1 [0 a1
 01-31 17:50:26.305: W/System.err(969): java.lang.InstantiationException: android.content.pm.IPackageManager
 01-31 17:50:26.305: W/System.err(969):     at java.lang.Class.newInstanceImpl(Native Method)
 01-31 17:50:26.315: W/System.err(969):     at java.lang.Class.newInstance(Class.java:1479)
 01-31 17:50:26.325: W/System.err(969):     at f.c.v.ClearUserDataUsingInterfaceActivity.onCreate(ClearUserDataUsingInterfaceActivity.java:52)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 17:50:26.355: W/System.err(969):  at           android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-31 17:50:26.355: W/System.err(969):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-31 17:50:26.365: W/System.err(969):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-31 17:50:26.365: W/System.err(969):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-31 17:50:26.375: W/System.err(969):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 17:50:26.375: W/System.err(969):  at android.os.Looper.loop(Looper.java:123)
01-31 17:50:26.385: W/System.err(969):  at android.app.ActivityThread.main(ActivityThread.java:4363)
01-31 17:50:26.385: W/System.err(969):  at java.lang.reflect.Method.invokeNative(Native Method)
01-31 17:50:26.395: W/System.err(969):  at java.lang.reflect.Method.invoke(Method.java:521)
01-31 17:50:26.395: W/System.err(969):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-31 17:50:26.405: W/System.err(969):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

01-31 17:50:26.405: W/System.err(969): at dalvik.system.NativeStart.main(Native Method)

and Full stacktrace.

 01-31 17:26:38.285: E/AndroidRuntime(920): Uncaught handler: thread main exiting due to uncaught exception
 01-31 17:26:38.295: E/AndroidRuntime(920): java.lang.RuntimeException: Unable to start activity ComponentInfo{f.c.v/f.c.v.ClearUserDataUsingInterfaceActivity}: java.lang.NullPointerException
 01-31 17:26:38.295: E/AndroidRuntime(920):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.os.Looper.loop(Looper.java:123)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.ActivityThread.main(ActivityThread.java:4363)
01-31 17:26:38.295: E/AndroidRuntime(920):  at java.lang.reflect.Method.invokeNative(Native Method)
01-31 17:26:38.295: E/AndroidRuntime(920):  at java.lang.reflect.Method.invoke(Method.java:521)
01-31 17:26:38.295: E/AndroidRuntime(920):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-31 17:26:38.295: E/AndroidRuntime(920):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-31 17:26:38.295: E/AndroidRuntime(920):  at dalvik.system.NativeStart.main(Native Method)
01-31 17:26:38.295: E/AndroidRuntime(920): Caused by: java.lang.NullPointerException
01-31 17:26:38.295: E/AndroidRuntime(920):  at java.lang.reflect.Method.invokeNative(Native Method)
1-31 17:26:38.295: E/AndroidRuntime(920):   at java.lang.reflect.Method.invoke(Method.java:521)
01-31 17:26:38.295: E/AndroidRuntime(920):  at f.c.v.ClearUserDataUsingInterfaceActivity.onCreate(ClearUserDataUsingInterfaceActivity.java:57)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 17:26:38.295: E/AndroidRuntime(920):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-31 17:26:38.295: E/AndroidRuntime(920):  ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:39:39+00:00Added an answer on May 29, 2026 at 6:39 am

    IPackageManager is an interface( as suggested by the ‘I’ prefix). You cannot instantiate an interface via reflection.

    I’m guessing you’ve meant android.content.pm.PackageManager

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to deploy a Rails3 app to Heroku, but am getting this 'Rake
What's the best design to use in an iPhone app that uses core data
I am trying to write a ruby app to update Google Contact Photos but
I'm trying to call an wcf self hosted method from jquery but, i'm aways
We have a folder where our app will be potentially reading, writing and creating/deleting
Ever since deleting the original settings.settings file I have had endless problems getting the
I' m trying to enable adding/deleting rows to/from table using folowing code: Script: $(document).ready(function()
I'm running into a crash issue while developing an iPhone app with Core Data.
Hi I am currently trying to building a reader app for the iphone, a
I'm working on an table drill-down style iPhone app that has prepopulated data. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.