0
我的應用程序包含一個ListView
在一個活動和一個BroadcastReciever
。觸發後,我想讓我的Broadcastreciever
刷新ListView
。我的接收器將內容放入sqlite數據庫,我的listview
顯示該數據庫的內容。android刷新listview from broadcastreciever
活動與ListView控件:
lv=(ListView) findViewById(R.id.conversation);
lv.setSelection(lv.getCount()-1);
lv.setAdapter(new mAdapter(this, srsList, messagesList, timesList, numbersList, idList));
registerForContextMenu(lv);
BroadcastReciever:
SQLiteDatabase db = dbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
//values.put(Messages.KEY_ID, i1);
values.put(Messages.KEY_sr, "r");
values.put(Messages.KEY_message, message);
values.put(Messages.KEY_time, datetime);
values.put(Messages.KEY_number, sen);
// Inserting Row
long student_Id = db.insert(Messages.TABLE, null, values);
db.close(); // Closing database connection