why this error occurs. I have already a database. And I add table and insert a item in it.I control this steps and when I insert item there is no error.But when I want to read which I put the item in my new table , this error occurs.It says I do not find.I control it in emulator , I push .db to my desktop and open it.I see in it and yes , there isn’t the new table.But It must be.
When I remove app and re install my app there isn t any problem , the tables are there. But I DONT WANTTO RE-INSTALL i want to upgrade. What can I do for this?
package xxxxx;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DB_NAME="xxx.db";
public static final String TABLE_NAME="already_exist";
public static final String TABLE_NAME2="already_exist2";
public static final String TABLE_NAME3="new_table";
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, 2);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, s TEXT)");
db.execSQL("CREATE TABLE " + TABLE_NAME2 + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, a TEXT,v TEXT)");
db.execSQL("CREATE TABLE " + TABLE_NAME3 + "(_id INTEGER PRIMARY KEY AUTOINCREMENT, x TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
}
}
1 Answer