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."
i have a problem in reading this information from the string addressString 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
BOOKNO, FROM, TO, LINK, SINCE
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
1,2011-02-28 07:00:52,2011-03-17 07:01:02,http://www.example.com,5
second row
2,011-03-01 17:55:15,2011-03-30 17:55:21,http://www.something.com,3
and i need to insert the first 5 columns and loop again to insert the next five addressString contains all the above information and its read as one string
and this is the code im using to read it
db.open();
long idx;
String lines[] = {addressString};
String fields[] = new String[lines.length];
for (int i = 0; i < lines.length; i++) {
for (int j=0; j<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]);
}
so what am i doing wrong in this code and how to make it work …..??
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
if (addressString != "didn't read titels"){
String lines[] = {addressString};
String fields[] = new String[lines.length];
for (int i = 0; i < 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]);
}
so.. why is it only reading and displaying the first line which is [1]
Check the value of lines.length. Looks like that it is returning 1.