3

I'm looking for a way to insert a new entry into a specific row in an sqlite database in android. The basic idea is that the database stores entries like this:

id   day        time
1   Monday     09:00
2   Monday     11:00
3   Tuesday    10:00

the ID column is auto incremented. The idea is that if you wanted to insert a new entry of "Monday 10:00" it should be inserted into the database at id 2, and the other entries would update accordingly i.e. the entry "Monday 11:00" would become id 3 etc.

In short, is there any way to insert data into a specific row? If there is, will it automatically change the other entries?

Thanks

2 Answers 2

2

Short answer, no. Auto increment means you don't control the field.

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

4 Comments

So basically it's going to be a case of getting all the entries, sorting them, then reinserting? Thanks for reply
Pretty much, maybe you should remove the auto-incerement property.
Why do you absolutely want the data to be sorted in the database ? In my opinion, it doesn't matter how the data is sorted in the DB the important is to show sorted rows.
It doesn't have to be sorted in the database, just means I have to rethink the method I have for removing items, as it stands atm, its just a case of getting ID from a list view and removing that ID. Thanks for replies, least I have an idea now :)
0

If you're looking to change a certain row in a table, you can use UPDATE.

INSERT INTO is for adding new rows.

Comments

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.