Android Question Inserting Into SQLite

Terradrones

Active Member
Hi All

Need help again please.

I have a SQLite database which has all the information on the widths of a road. It consists of the following:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
1000.000 6.000 6.000
......etc.

I want insert a Stake between SV 120 and SV 1000, that it looks as follows:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
900.000 5.000 5.000
1000.000 6.000 6.000
......etc.

At the moment I am reading the Database into an array, sorting the array and then writing everything back into the database.

Is there an easier way?

Thanks
Michael
 

KMatle

Expert
Licensed User
Longtime User
and then writing everything back into the database

It's all about the design of your database. You should only write back the new/changed entries.


sorting the array

Let SQlite do the sort for you (via ORDER BY <column name> ASC or DESC). So the result set is already sorted.

Which column names do you use? Or do you store anything int ONE column (which is bad)?
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Hi All

Need help again please.

I have a SQLite database which has all the information on the widths of a road. It consists of the following:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
1000.000 6.000 6.000
......etc.

I want insert a Stake between SV 120 and SV 1000, that it looks as follows:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
900.000 5.000 5.000
1000.000 6.000 6.000
......etc.

At the moment I am reading the Database into an array, sorting the array and then writing everything back into the database.

Is there an easier way?

Thanks
Michael
>>
Hi All

Need help again please.

I have a SQLite database which has all the information on the widths of a road. It consists of the following:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
1000.000 6.000 6.000
......etc.

I want insert a Stake between SV 120 and SV 1000, that it looks as follows:

Stake Left Width Right Width
0.000 5.000 5.000
120.000 5.000 5.000
900.000 5.000 5.000
1000.000 6.000 6.000
......etc.

At the moment I am reading the Database into an array, sorting the array and then writing everything back into the database.

Is there an easier way?

Thanks
Michael
>> I want insert a Stake between

That is the principal mistake. You can't and shouldn't rely on a presumed location of a row in the table.

RBS
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I want insert a Stake between SV 120 and SV 1000
You had asked the same exact question two months ago in the below thread and you were given plausible answers::
We know you are a good surveyor, but if you want to be a good programmer, you have to either trust the answers you are given, or if they are not satisfactory, you should have continued to challenge them in that thread until you got satisfaction. The least you could have done is refer to the old thread.
 
Upvote 0
Top