i am unable to create second table in android

by ram » Tue, 09 Feb 2010 01:42:52 GMT

Sponsored Links
 this is helper class .
i m unable create a second table in my sqlite
please observe the following code

helper class.java

public class DBAdapter {

    private static final String DATABASE_NAME="satya_db";
    private static final int DATABASE_VERSION=1;
    private static Context context;
    private SQLiteDatabase db=null;

    private static String CREATE_TABLE="create table states(_id
integer primary key autoincrement,sna varchar(13) not null)";
    private static String CREATE_TABLE_P="create table places(_id
integer primary key autoincrement,pna varchar(13) not null)";
    public DBAdapter(Context ctx)


    private static class DatabaseHelper extends SQLiteOpenHelper {

        DatabaseHelper(Context ctx) {
        super(ctx, DATABASE_NAME, null, DATABASE_VERSION);


        public void onCreate(SQLiteDatabase db) {
         db.execSQL(CREATE_TABLE );

        public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
            // TODO Auto-generated method stub


        public DBAdapter open()
            DatabaseHelper dbhelper=new DatabaseHelper(context);
            return this;

        public void close()

        public long insertRow(String sna)
            ContentValues cv=new ContentValues();
            cv.put("sna", sna);

            return db.insert("states",null,cv);
        public long insertRowP(String pna)
            ContentValues cv=new ContentValues();
            cv.put("pna", pna);

            return db.insert("places",null,cv);
        public int updateRow(ContentValues cvs,String p[])
            return db.update("states", cvs,"_id=?",p);

        public Cursor equery()
            return db.rawQuery("select * from states where
main class java

package touchmeme.Datalist;

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

public class Datalist extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
                DBAdapter db= new DBAdapter();



Other Threads

1. How to launch an application? Is there a work around for launchMode bug?


What is the proper way to launch an application on Android?
I tried all possible launchMode values, but all of them fail with
several different problems (see below).

This question was already asked many times, for example

2. Not getting console prompt...

Add "init=/init" to your bootargs..

-- Ashwin

unsubscribe: android-porting+unsubscr...@googlegroups.com
website:  http://www.***.com/ 

3. how mdm is possible in android

4. Flash di ptk

5. 2.1 vs 2.2 ZipInputStream

6. Running an app within another app

7. Spica Terendam Air