我有一个listview,其中包含来自SQLite表的元素,当我删除表的内容并尝试刷新listview时,我得到一个null异常
我做以下
var Car = function(x){
this.x = x;
this.y = 10;
};
var Van = function(x){
Car.apply(this, arguments);
};
Van.prototype = Object.create(Car.prototype);
Van.prototype.constructor = Car;
Car.prototype.say_position = function(){
console.log("("+this.x+", "+this.y+")");
}
var car = new Car(2);
car.say_position(); //(2, 10)
var van = new Van(2);
van.say_position(); //(2, 10)
我将如何从一个不包含任何内容的表中刷新我的列表视图?
来自LogCat的消息
mHelper.clearDatabase("TableName");
Adapter.clear();
Adapter.notifyDataSetChanged();
public void clearDatabase(String TABLE_NAME) {
SQLiteDatabase db = this.getWritableDatabase();
String clearDBQuery = "DELETE FROM "+TABLE_NAME;
db.execSQL(clearDBQuery);
}
答案 0 :(得分:0)
我想我应该加上像
这样的东西Adapter = new SettingsCursorAdapter(getBaseContext(),AllContacts);在我打电话之前 Adapter.swapCursor(AllContacts);