简体   繁体   中英

Android sqlite deleting and inserting rows

I am having trouble managing my app with a SQLite Database.

Here's how I would like the app to flow and how the SQLite Db should look.

When you launch it the first time it puts three rows of data in based on some starter objects.

Id_ 1 "Bob" Id_2 "Bill" Id_3 "Steve"

At different points when the app is being used the user can choose to add a new row.

delete (Bob) Id_1 "Bob" Id_2 "Bill" Id_3 "Steve" Id_4 "Tony"

Also, the user can delete a row based upon the name of the object.

delete(Bob) Id_1 "Bill" Id_2 "Steve" Id_3 "Tony

When I just use an Adapter class to delete the row (or all the rows) and then try to insert a new row, it deletes the row and doesn't the others to fill that gap. How can I fill that in?

Do I need to find that row, then update that row with the values from the next row and repeat that until I have moved them all down?

If you made changes to the DB for data in an active cursor, simply use the requery method and your list will refresh along with the cursor.

yourCursor.requery();

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM