我有数据库,我想删除包含整数值的_id列值的行。
这是我的数据库:
public class ContactDatabase extends SQLiteOpenHelper {
SQLiteDatabase db;
public static final String DATABASE_NAME="totalContact.db";
public static final String TABLE_NAME="mecontact";
public static final String NAME="name";
public static final String PHONE="phone";
public static final String UID="_id";
public ContactDatabase(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL("create table mecontact" +
"(_id integer primary key autoincrement, name text, phone text)");
}catch(android.database.SQLException e){
System.out.println("table create nhi ho rha");
}
}
public void deleteContact(String d,int pos){
db=this.getWritableDatabase();
{String.valueOf(pos) });
db.delete(TABLE_NAME, "_id = ?", new String[]{String.valueOf(pos)});
db.close();
}
}
我使用了很多查询,例如:
db.delete(TABLE_NAME, UID + "= ?", new String[] {String.valueOf(pos) });
db.delete(TABLE_NAME, "name = ? '" + d + "'" + " AND _id ? = ", new String[] {String.valueOf(pos) } );
db.delete(TABLE_NAME, "name = ? AND _id = " + pos, new String[]{ d });
但是没有人在工作,所以我很沮丧。