1

alright, So when i call

ourDatabase.delete(DATABASE_TABLE, KEY_ROWID + "=" + lrow, null);

which is a delete function for my database, it works and deletes the long i send to it as lrow, the problem i have is then when it deletes the one i pick it leaves all the numbers in the database the same. example i have a list of words 1-10 in a database it shows "1,2,3,4,5,6,7,8,9,10". I delete number 4 and then in the list showing the word it shows "1,2,3,5,6,7,8,9,10" - No 4. Is there anyway this can be fixed and have it count the new amount i have and reset the database. so it would show "1,2,3,4,5,6,7,8,9"

How i get the data is through an array that has each length of the words in my database.

Hope you understand, if not post a comment!

1 Answer 1

3

Not exactly sure what the problem is... maybe the numbers you are referring to are some ID for example for your entries in your database?

You could update all the entries with numbers higher than the one you deleted to decrease by one... the update function will not really work with the ContentValues, but you could try this:

ourDatabase.execSQL("UPDATE "+DATABASE_TABLE+" SET "+KEY_ROWID+"="+KEY_ROWID+"-1 WHERE +"KEY_ROWID+">"+lrow);

But it's really ugly... I think you should look more at why you need this and is it really necessary...

Sign up to request clarification or add additional context in comments.

2 Comments

Hmm, didnt seem to work. But thanks! i added a plus that you forgot but still not working.
When I was debugging databases, I was using SQLiteManager extension for Firefox and running the commands there first... maybe you could find out what's going wrong there...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.