Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete Event From android returns Null Pointer Exception
    primarykey
    data
    text
    <p>When I try to delete a specific event from my calendar it returns NULL Pointer Exception </p> <p>But when I delete all the events it works fine </p> <p>I got the path from insertion query and tried almost everything </p> <p>This is my code </p> <p>My Delete Event Class</p> <pre><code>public class DeleteEvent extends Activity { public DeleteEvent() { // TODO Auto-generated constructor stub } public int DeleteCalendarEntry(int entryID) { int iNumRowsDeleted = 0; Uri eventsUri = Uri.parse( "content://com.android.calendar/events"); Uri eventUri = ContentUris.withAppendedId(eventsUri, entryID); iNumRowsDeleted = getContentResolver().delete(eventUri, null, null); return iNumRowsDeleted; } } </code></pre> <p>/////////////////////////////////////////////////////</p> <pre><code>image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chose_add_view_delete(); } }); </code></pre> <p>When click cell execute this :- </p> <pre><code>public void chose_add_view_delete() { final CharSequence[] items = { "Add Event", "View Event","Delete Event" }; AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("What !?"); builder.setSingleChoiceItems(items, 0,new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub if (which == 0) { DeleteEvent del = new DeleteEvent(); int i = del.DeleteCalendarEntry(82); dialog.dismiss(); } </code></pre> <p>/////////////////////////////////////////////////</p> <pre><code>09-10 12:28:01.385: E/AndroidRuntime(22297): FATAL EXCEPTION: main 09-10 12:28:01.385: E/AndroidRuntime(22297): java.lang.NullPointerException 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.content.ContextWrapper.getContentResolver(ContextWrapper.java:90) 09-10 12:28:01.385: E/AndroidRuntime(22297): at com.iphase.Albayan.DeleteEvent.DeleteCalendarEntry(DeleteEvent.java:25) 09-10 12:28:01.385: E/AndroidRuntime(22297): at com.iphase.Albayan.MainActivity$9.onClick(MainActivity.java:475) 09-10 12:28:01.385: E/AndroidRuntime(22297): at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:935) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.widget.ListView.performItemClick(ListView.java:3746) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1980) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.os.Handler.handleCallback(Handler.java:587) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.os.Handler.dispatchMessage(Handler.java:92) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.os.Looper.loop(Looper.java:130) 09-10 12:28:01.385: E/AndroidRuntime(22297): at android.app.ActivityThread.main(ActivityThread.java:3691) 09-10 12:28:01.385: E/AndroidRuntime(22297): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 12:28:01.385: E/AndroidRuntime(22297): at java.lang.reflect.Method.invoke(Method.java:507) 09-10 12:28:01.385: E/AndroidRuntime(22297): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 09-10 12:28:01.385: E/AndroidRuntime(22297): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 09-10 12:28:01.385: E/AndroidRuntime(22297): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload