开发者

Android Database not updating or deleting

开发者 https://www.devze.com 2023-03-16 03:33 出处:网络
So basically my database was working for a little while (very glitchy though, had to basically restart my application to see the change in my list view).

So basically my database was working for a little while (very glitchy though, had to basically restart my application to see the change in my list view).

This is a two part question:

I use a customized adapter and use

ea.notifyDataSetChanged();

to try and update my adapter. But I th开发者_JAVA技巧ink the problem lies that the arrays don't update as well.

List<String> rList = db.selectAllReceive();
    receiveMessages = rList.toArray(new String[rList.size()]);

Should I just update the array inside the adapter?

Part two:

db.delete(clicked);
        Toast.makeText(getBaseContext(), "Deleted Row: " + clicked, Toast.LENGTH_SHORT);
        Log.i("ContextMenu", "[MainAct.Class] Clicked DELETE");
        ea.notifyDataSetChanged();

This is my code that is within my onContextItemSelected(). I get my log, but I do not get a Toast or notice any database deletion.

Maybe it all comes down to the fact that the array is not updated enough? Should I create a method to update the arrays and use it after it?

Thanks


Without the whole class/classes, hard to say for sure, but I would presume a threading issue. The Toast message not showing up suggests this (I think), I would check into if you're doing the threading properly for dealing with the database updates and list view updating.


using mListView.setAdapter(adapter) can solve all of thing,maybe a little Efficiency problem,but if the datasouce not big,It's conld bear.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号