Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid sqlite looping to read and insert
    primarykey
    data
    text
    <pre><code>addressString = "BOOKNO= [1] From= [ 2011-02-28 07:00:52] To= [2011-03-17 07:01:02] Link= [http://www.example.com] SINCE= [5] days. BOOKNO= [2] From= [ 2011-03-01 17:55:15] To= [2011-03-30 17:55:21] Link= [http://www.something.com] SINCE= [3] days." </code></pre> <p>i have a problem in reading this information from the string <code>addressString</code> and inserting it into an sqlite tabel so this is the information that im suppose to read i should only extract the text that is between brackets so the table should look like this </p> <p><code>BOOKNO, FROM, TO, LINK, SINCE</code></p> <p>those are the five columns that i need to insert into my table so im using indexof() to extract whats between the brackets and my first row should only contain </p> <pre><code>1,2011-02-28 07:00:52,2011-03-17 07:01:02,http://www.example.com,5 </code></pre> <p>second row</p> <pre><code>2,011-03-01 17:55:15,2011-03-30 17:55:21,http://www.something.com,3 </code></pre> <p>and i need to insert the first 5 columns and loop again to insert the next five <code>addressString</code> contains all the above information and its read as one string and this is the code im using to read it </p> <p>db.open();<br> long idx;</p> <pre><code> String lines[] = {addressString}; String fields[] = new String[lines.length]; for (int i = 0; i &lt; lines.length; i++) { for (int j=0; j&lt;5; j++){ int be = lines[i].indexOf('['); int e = lines[i].indexOf(']'); fields[i] = lines[i].substring(be+1, e); } idx = db.insertTitle(fields[0],fields[1],fields[2],fields[3],fields[4]); } </code></pre> <p>so what am i doing wrong in this code and how to make it work .....??</p> <p>hi to all again i've been playing around with my code and when i try to show the output on the screen with this code i get only number 1 on the screen it does not read all the text that is in address string </p> <pre><code>if (addressString != "didn't read titels"){ String lines[] = {addressString}; String fields[] = new String[lines.length]; for (int i = 0; i &lt; lines.length; i++) { int be = lines[i].indexOf('['); int e = lines[i].indexOf(']'); fields[i] = lines[i].substring(be+1, e); myLoutputText.setText(fields[i]); } </code></pre> <p>so.. why is it only reading and displaying the first line which is [1]</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload