Passing string var across onClick
<p>I'm trying to better understand SQLite for android and ran into an issue. My test program simply has a textbox, and button. When you enter text into the textbox and click the button I want it to create a new 'contact' (database class).</p>

<pre><code>public class Home extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    DatabaseHandler db = new DatabaseHandler(this);
    String name = "";



    Button upButton = (Button) findViewById(R.id.button1);

    upButton.setOnClickListener(new View.OnClickListener() {            
        @Override
        public void onClick(View v, String name) {
            EditText editText = (EditText)findViewById(R.id.editText1);


            name = editText.getText().toString();
            TextView textView = (TextView)findViewById(R.id.textView2);
            textView.setText(name);


        }

    });
    db.addContact(new Contact(1,name));
}
</code></pre>

<p>}</p>

<p>As you see when they click it saves whatever is in the textbox as name. I simply want to be able to send it down to the addContact function call. I also was a bit confused on how to use my db class inside the onClick function? Ideally I would simply like to update it inside the onClick, or would I?</p>
