//删除所有数据代码,可以实现
public long DeleteAllSms() {
open();
return db.delete(DB_TABLE_COURSE,null,null);
}//删除一项数据,却不能,函数始终返回0
public int removeSubject(int index) {
open();
String where = KEY_ID+"="+index;
return db.delete(DB_TABLE_COURSE,where, null);
}大家觉得可能是哪方面的问题呢,有没有遇到这问题的兄弟姐妹,真心求教!!!
public long DeleteAllSms() {
open();
return db.delete(DB_TABLE_COURSE,null,null);
}//删除一项数据,却不能,函数始终返回0
public int removeSubject(int index) {
open();
String where = KEY_ID+"="+index;
return db.delete(DB_TABLE_COURSE,where, null);
}大家觉得可能是哪方面的问题呢,有没有遇到这问题的兄弟姐妹,真心求教!!!
解决方案 »
- ListView中的CheckTextView无法选中
- sharepreference不同应用之间进行读写
- 急求:TabHost下的Tab的activity跳转
- 急!!!在edittext内输入字符,scollview自动下滑,是什么情况?
- view.layout(int, int, int, int)设置view的大小和位置不成功
- 请教从相机获得视频流实时传输问题
- PreferenceScreen加载一个自定义布局layout,怎么设置监听
- 如何判断手机是横着还是竖着拿的
- 安卓手机的输入问题
- android拍照
- 关于EditText上下文的问题
- 用eclipse的编辑tabhost下的其他tab的问题
key_id 确认存在?
private static final String TB_CREATE_COURSE = "CREATE TABLE "+
DB_TABLE_COURSE+" ("+KEY_ID+" Integer primary key autoincrement,"+
KEY_DAY_OF_WEEK +" text not null," +
KEY_START_WEEK+" text not null,"+
KEY_END_WEEK +" text not null,"+
KEY_TEACHER_NAME+" text not null,"+
KEY_COURSE_NAME +" text not null,"+
KEY_TEACH_PLACE+" text not null,"+
KEY_CURRENT_WEEK+" text not null,"+
KEY_START_LESSION_TIME+" text,"+
KEY_END_LESSION_TIME +" text);";
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
selectedItem = arg2;
new AlertDialog.Builder(AnimationTest.this).setIcon(R.drawable.icon).
setTitle("课程设置").setPositiveButton("删除课程",
//创建DialogInterface.OnClickListener对象实例,当单击按钮时调用onClick方法
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println(dbAdapter.removeSubject(selectedItem)+"返回值");
if(dbAdapter.removeSubject(selectedItem)>0) {
simpleAdapter.notifyDataSetChanged();
listView.setAdapter(simpleAdapter);
Toast.makeText(AnimationTest.this, "删除成功", Toast.LENGTH_SHORT).show();
}
else {
System.out.println("删除不成功");
System.out.println(selectedItem);
}
}
}).setNegativeButton("更改课程",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create().show();
}
});
一目了然