我收到未找到表的错误。我搜索了很多但无法找到错误的来源
public class update extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.update);
Button upbtn=(Button)findViewById(R.id.upbutton);
final EditText detedit=(EditText)findViewById(R.id.upedit);
final EditText amtedit=(EditText)findViewById(R.id.editText1);
stdb obj=new stdb(this);
final SQLiteDatabase dobj=obj.getWritableDatabase();
upbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String setdet,setamt;
setdet=detedit.getText().toString();
setamt=amtedit.getText().toString();
//try{
String insertQuery = "INSERT INTO " +stdb.tname+" (" + stdb.details+" , "+stdb.amt+") VALUES("+setdet+" , "+setamt+");";
//Log.e("sql",insertQuery);
dobj.execSQL(insertQuery);
//}
//catch(SQLException e ){
// Log.e("sqlite",e.toString());
//}
}
});
}
}
SQLiteOpenHelper:
public class stdb extends SQLiteOpenHelper {
private static final int version = 1;
public static final String dname = "statments.db";
public static final String tname="transactions";
public static final String sid = "sno";
public static final String details = "details";
public static final String amt = "amount";
public stdb(Context context) {
super(context, dname, null, version);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
String ex="CREATE TABLE " + tname + " (" + sid + " INTEGER PRIMARY KEY AUTOINCREMENT," + details+ " VARCHAR(255),"+amt+" INTEGER);";
Log.e("ex",ex );
db.execSQL("CREATE TABLE " + tname + " (" + sid + " INTEGER PRIMARY KEY AUTOINCREMENT," + details+ " VARCHAR(255),"+amt+" INTEGER);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS "+ tname);
onCreate(db);
}
}