Android Studio
本人初学android ,求帮忙看看有什么问题!
public class ShujuSQLiteHelper extends SQLiteOpenHelper {
public ShujuSQLiteHelper(Context context){
super(context,"shuju.db",null,5);
}
//当goods.db创建完成的时候,调用onCreate方法,在其中创建数据表
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table shuju(id integer primary key autoincrement," +
"name varchar(20)," +
"price integer)" );
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
Caused by: android.database.sqlite.SQLiteException: no such table: shuju (code 1): , while compiling: alter table shuju add account varchar(20) default 1000
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
at com.example.lenovo.gaoxiao30.ShujuSQLiteHelper.onUpgrade(ShujuSQLiteHelper.java:24)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
at com.example.lenovo.gaoxiao30.ShujuDao.query(ShujuDao.java:51)
at com.example.lenovo.gaoxiao30.ShujuActivity.onCreate(ShujuActivity.java:34)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)