I have a CursorAdapter
which fetch data from SQLite
Database and provides views for a list. Now I want to delete an item in list without deleting data from DB. As you can see here, it is possible to change view of specific item without changing the data-set. But removeViewAt(int index)
is not supported in ListView
. Is it possible to remove an item without changing DB?
Asked
Active
Viewed 57 times
-1

hasanghaforian
- 13,858
- 11
- 76
- 167
-
remove it from ArrayList object that populated from Db – Amrdroid Jan 06 '19 at 14:47
-
@Amrnoid Here list uses `CursorAdapter`. – hasanghaforian Jan 06 '19 at 14:49
-
Are you able to add a new column with a boolean for `deleted`? You can change your adapter's `getView()` to hide those rows where `deleted == true`. – Dan Harms Jan 06 '19 at 15:04
-
try to append the deleted id of item in select query with not equal statement – Amrdroid Jan 06 '19 at 15:08
-
@dharms How I can hide those rows? – hasanghaforian Jan 06 '19 at 15:13
-
Set the row's visibility to `GONE`. – Dan Harms Jan 06 '19 at 15:14
-
@Amrnoid Yes, it is an option that must work which I did not think about that. But I wait for a way without need to re-querying the DB. – hasanghaforian Jan 06 '19 at 15:15
-
@dharms setting visibility of view of row to `GONE` leaves the row empty; but the empty row and its bounds are visible. – hasanghaforian Jan 06 '19 at 15:45
-
@Amrnoid Please add your comment as answer, so I can mark it as accepted answer. – hasanghaforian Jan 06 '19 at 15:49
-
thnx , i hope it solved your problem – Amrdroid Jan 06 '19 at 15:59
-
You need to do it to row's parent view. If you are doing a child view it will not work. – Dan Harms Jan 06 '19 at 16:02