Onclick giving error wen used with data base functions

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Onclick giving error wen used with data base functions

Postby android devloper » Tue Jul 28, 2009 5:36 am

hi all,
i'm quite new to android .....in the following code that i'm getting error on click of a button,which is tasked to retrive some data from data base...please help me out...
thanks in advance.


regards



package com.DatabaseActivity;



import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class DatabaseActivity extends Activity {
/** Called when the activity is first created. */
EditText txt1,txt2,txt3;
Button bt1,bt2;
TextView tv;
final DBAdapter db = new DBAdapter(this);
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);



db.open();

bt1=(Button)findViewById(R.id.Button01);
//bt2=(Button)findViewById(R.id.Button02);

click cl=new click();
bt1.setOnClickListener(cl);
// bt2.setOnClickListener(cl);
db.close();

}



class click implements Button.OnClickListener{

@Override
public void onClick(View v) {
tv=(TextView)findViewById(R.id.TextView01);
txt1=(EditText)findViewById(R.id.EditText01);
txt2=(EditText)findViewById(R.id.EditText02);
txt3=(EditText)findViewById(R.id.EditText03);
if(v.getId()==R.id.Button02){
Cursor c=db.getTitle(2);
if (c.moveToFirst())
DisplayTitle(c);

}

}

}


public void DisplayTitle(Cursor c)
{
txt1.setText(c.getString(0));
txt2.setText(c.getString(1));
txt3.setText(c.getString(2));
}



}
android devloper
Freshman
Freshman
 
Posts: 4
Joined: Sun Jul 26, 2009 8:28 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests