passing value of database handler object in to onClickListener
<p>I need help on passing value of database helper object to onCilckListener..</p>

<p>The database helper works fine if it's outside the listener.. But the application stops due to an exception when it is used inside the listener.. Please help me..</p>

<pre><code>package com.example.helloandroid;

import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        DatabaseHandler dbpin = new DatabaseHandler(this);


        // Inserting Pin
        Log.d("Insert: ", "Inserting Pin ..");
        dbpin.addPin(new Pin("1111"));
        Log.d("Reading: ", "Reading pin at id=0..");

        Pin cn1 = dbpin.getPin(0);
        String log1 = cn1.getPin() ;
          Log.d("Name: ", log1);     //this works.. i want the value of log1 inside OnClickListener of imageButton1

        ImageButton next2 = (ImageButton) findViewById(R.id.imageButton1);
        next2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

            EditText pinget = (EditText)findViewById(R.id.editText1);


                 Log.v("EditText", pinget.getText().toString());



             //pin validator

          //value of log1 should be retrieved here to compare it in the if condition

                      if (pinget.getText().toString().equals("0000")) {
                Intent myIntent = new Intent(view.getContext(), home.class);
                startActivityForResult(myIntent, 1);
                }
                 else {
                     Intent myIntent = new Intent(view.getContext(), Main1.class);
                     startActivityForResult(myIntent, 1);
                 }

            }                

        });      
    }      
      }
</code></pre>
