Android and Java exception
<p>I am a little rusty at my java. I'm sure its a java issue and not an android issue but I'll tag both. When I click the delete button it throws an exception. the cItem in the click listener is null. I'm not sure why ... any help would be great.</p>

<pre><code>protected boolean onTap(int index) {
    FishOverlayItem item = (FishOverlayItem)mOverlays.get(index);
    if(item != null) {
        Dialog dialog = new Dialog(mContext);
        dialog.setContentView(R.layout.view_fish_dialog);
        dialog.setTitle("Recorded Fish");
        TextView tv = (TextView) dialog.findViewById(R.id.textViewSpecie);
        tv.setText(item.getTitle());
        tv = (TextView) dialog.findViewById(R.id.textViewLat);
        tv.setText(item.gLat + " deg Lat");
        tv = (TextView) dialog.findViewById(R.id.textViewLon);
        tv.setText(item.gLon + " deg Lon");

        class FishClickListener implements OnClickListener{

            protected Dialog cDialog;
            protected FishOverlayItem cItem;

            public FishClickListener(Dialog dialog, FishOverlayItem item) {
                // TODO Auto-generated constructor stub
                cDialog = dialog;
                cItem = item;
            }

            public void onClick(View arg0) {
                // TODO Auto-generated method stub

            }               
        }

        Button cancel = (Button) dialog.findViewById(R.id.viewFishCancel);
        cancel.setOnClickListener(new FishClickListener(dialog, item) {
            public void onClick(View v) {
                // cancel
                cDialog.dismiss();
            }
        });

        Button delete = (Button) dialog.findViewById(R.id.viewFishDelete);
        delete.setOnClickListener(new FishClickListener(dialog, item) {
            public void onClick(View v) {
                // delete and dismiss dialog
                FishDBAdapter dbAdapter = new FishDBAdapter(mContext);
                dbAdapter.deleteLocation(cItem.gId);
                cDialog.dismiss();
            }
        });
</code></pre>

<p>Here is the logcat ...</p>

<pre><code>08-10 20:04:13.882: ERROR/AndroidRuntime(23567): FATAL EXCEPTION: main
08-10 20:04:13.882: ERROR/AndroidRuntime(23567): java.lang.NullPointerException
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at com.rs.android.fishingatlas.FishDBAdapter.deleteLocation(FishDBAdapter.java:51)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at com.rs.android.fishingatlas.FishOverlay$2.onClick(FishOverlay.java:74)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.view.View.performClick(View.java:2461)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.view.View$PerformClick.run(View.java:8888)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.os.Handler.handleCallback(Handler.java:587)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.os.Looper.loop(Looper.java:123)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at android.app.ActivityThread.main(ActivityThread.java:4627)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at java.lang.reflect.Method.invokeNative(Native Method)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at java.lang.reflect.Method.invoke(Method.java:521)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:859)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617)
08-10 20:04:13.882: ERROR/AndroidRuntime(23567):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
