I am trying to create database and table on the click event of
button... when I am clicking on the button for creating database and
table... it is saying that process com.example.hw3 has stopped
unexpectedly...please try again... Below is the code... what wrong I
am doing....??
Somebody Please help me....





package com.example.hw3;


import java.util.Locale;

import android.app.Activity;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class HW3 extends Activity {
        private Button b1;
        //private HW3DbAdapter db1;
        private EditText text;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        text = (EditText) findViewById(R.id.EditText01);
        initControls();
    }

    protected void initControls()
    {
    b1 = (Button)findViewById(R.id.CreateDB);

    b1.setOnClickListener(new Button.OnClickListener()
    { public void onClick (View v){ DoWork(); }});
    }

    protected void DoWork()
    {

        SQLiteDatabase db;

    //  db1 = new HW3DbAdapter(this);
        text.setText("Button 1 was clicked");
      // db1.open();
        //fillData();

       db = openOrCreateDatabase(
                        "db_hw3.db"
                        , SQLiteDatabase.CREATE_IF_NECESSARY
                        , null
                        );
       db.setVersion(1);
       db.setLocale(Locale.getDefault());
       db.setLockingEnabled(true);
       final String CREATE_TABLE_COUNTRIES =
        "CREATE TABLE db_entry ("
        + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
        + "mb_text TEXT NOT NULL,"
        + "ph_location TEXT);";

       db.execSQL(CREATE_TABLE_COUNTRIES);


    }



}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to