File and VCF

slowtime

Active Member
Licensed User
Longtime User
Hi,

I have got a Samsung Galaxy s and I can't use phone lib to retrieve phone contacts.
I'am writing a sub to retrive contacs from vcf file.

But when I precess vcf file (all contacts from export to sd card) I found a strange null line after

PHOTO: ......
......
.......
(STRANGE NULL STRING)
NOTE:....
.....

While I read lines I can't process this blank line by
...

line=file.readstring

if line.substring2(0,2)="N:" then
...
else if line="" or line.lenght <1 then
.....

end if

the same if I use

Dim List1 As List
List1 = File.ReadList(File.DirDefaultExternal, "00001.VCF")

for x=0 to list1.size -1

temp=list1.get(x)

if temp.substring2(0,2)="N:" then
....
else if temp.substring2(0,3)="TEL" then
...

END IF
NEXT

Application stops because this blank string begins with a not common ascci char.

Can someone helps me ?

Thank you
 

slowtime

Active Member
Licensed User
Longtime User
Hi Erel,

Part of file vcf:

TITLE:
PHOTO;ENCODING=BASE64;JPEG:/9j/4AAQSkZJRgABAQAAAQABAAD 2wBDAAEBAQEBAQEBAQE
....
.....
....
hCOiiunX3n/8AIfiuq5j/2Q==

NOTE;ENCODING=QUOTED-PRINTABLE:=
...
...

The line blank between " hCOiiunX3n/8AIfiuq5j/2Q==" and "NOTE;ENCODING=QUOTED-PRINTABLE:="

Basic 4 Android 1.50 debug this line

[sub main_loadlv]

If a1.SubString2(0,2)="N:" Then

ERROR: An error occurred in sub main_loadlv java line 1399 StringIndexout of bound exception

Ciao

ps: Debbugger is wonderful
 
Upvote 0

slowtime

Active Member
Licensed User
Longtime User
Hi Erel,

I tried it, but it is not a solution.

Dim List1 As List
List1.Initialize
TextReader1.Initialize(File.OpenInput(File.DirDefaultExternal,"00001.vcf"))

line = "Begin"
Do While line <> Null

line = TextReader1.ReadLine
If line.Length >2 Then
List1.Add(line)
End If
Loop
TextReader1.Close

on device: Program paused on line ...
if line.lenght >2

on debbuger : if line.lenght .. (yellowed)
line= null

I hope you can find a solution because I have not any idea.

Ciao
 
Upvote 0

slowtime

Active Member
Licensed User
Longtime User
Hi,

I attach an application reduct.

It normaly run only if you remove the blank line beetwen :

WIappaxm7TnHScFtbX+E3r26XWrs7//Z

(and)

NOTE:GGG BBB

Thank you for help.
Ciao
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
As I wrote before, this code is wrong:
B4X:
    line = TextReader1.ReadLine
    Do While line <>  Null
    
    line = TextReader1.ReadLine
        If line.Length > 2 Then
            If line.SubString2(0,2) ="N:" Then
                List.Add(line)
            End If
        End If
    Loop
You should read the line as the last action in the loop. Otherwise when it is null you are trying to work with it.
 
Upvote 0

slowtime

Active Member
Licensed User
Longtime User
Thank you Erel. You are magic.

If nobody is writing a module or a lib, what do you think if I post (in this thread or in share application) the complete sub to help galaxy s owners to put contacs from VCF in apps variables or sql database?
Thank you again.
Ciao
 
Upvote 0
Top