SQLite(二)

对应的Activity代码:

public class SqLiteDemoActivity extends Activity {

    private Button btn1=null;

    private Button btn2=null;

    private Button btn3=null;

    private Button btn4=null;

    private Button btn5=null;

    private Button btn6=null;

    private TextView datatxt=null;

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        btn1=(Button)findViewById(R.id.btn);

        btn1.setOnClickListener(new OnClickListener(){

           public void onClick(View v) {

              // TODO Auto-generated method stub

              System.out.println("the db is create");              

              SqlHelper db=new SqlHelper(SqLiteDemoActivity.this, "myhome.db");

               db.getWritableDatabase();

               Toast.makeText(SqLiteDemoActivity.this, "db", Toast.LENGTH_LONG).show();

           }

        

        });   

        btn2=(Button)findViewById(R.id.btn2);

        btn2.setOnClickListener(new OnClickListener(){

           public void onClick(View v) {

              // TODO Auto-generated method stub

              SqlHelper db=new SqlHelper(SqLiteDemoActivity.this, "myhome.db",3);

               db.getWritableDatabase();

               System.out.println("db is update");

               db.close();

           }

        

        });

        

 

posted @ 2011-08-29 22:59  rorshach  阅读(129)  评论(0编辑  收藏  举报