2

hi i needed to create multiple tables in my database in my android app. in my DBhelper class i have something like this to create my tables

my table name is TABLE_AREA = 'area'

public void onCreate(SQLiteDatabase db) {
    String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_USRS + "("
            + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + KEY_NAME + " TEXT,"
            + KEY_E_ADDR + " TEXT," + KEY_PASS + " TEXT" + ")";
    String CREATE_AREA_TABLE = "CREATE TABLE " + TABLE_AREA + "(" + KEY_AID + " INTEGER PRIMARY KEY AUTOINCREMENT ," + KEY_ANAME + " TEXT" + ")";

    db.execSQL(CREATE_CONTACTS_TABLE);
    db.execSQL(CREATE_AREA_TABLE);


}

and when adding the record i have something like this

public void addNArea(Area are)
{
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_ANAME, are.getArea());
    db.insert(TABLE_AREA, null, values);
    db.close();
}

the problem is it is saying that i dont have table named area. any ideas what im doing wrong?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
BourneShady
  • 955
  • 2
  • 17
  • 36

1 Answers1

0

After seen your code can't get any idea, try to clear your app data and then again create Tables.. if there is already existing Tables then it will not create new.!

for more see My SqLite Class example it will help you.. SQLite Database Example

Uttam Panchasara
  • 5,735
  • 5
  • 25
  • 41