Android Question SQLite

Terradrones

Active Member
Hi, I need advise again please.

I create a Folder (Directory) using this code:

See the bold section.

B4X:
[/
Sub AddEntry
    'we check if all fields are filled
    If Text1.Text = "" Then
        Msgbox2Async("Data Is Missing ", "Data", "OK", "", "", Null,False)
        Return
    End If
   
    'we check if an entry with the same name already exists
    If CGlobals.Code=1 Then            '******************************** Sites
       
       [B] If File.IsDirectory(File.DirInternal & "/QESS/DATA/",Text1.Text.ToUpperCase)=False Then
            File.MakeDir(File.DirInternal & "/QESS/DATA/",Text1.Text.ToUpperCase)
            CGlobals.Site=Text1.Text.ToUpperCase
            CGlobals.Job=""
            Activity.Finish
        Else if File.Exists(File.DirInternal & "/QESS/DATA/",Text1.Text.ToUpperCase)=True Then
            'Site/Folder already exists
            Msgbox2Async(Text1.Text.ToUpperCase & " Already Exists", "Site Exits", "OK", "", "", Null,False)
            Text1.Text=""
            Text1.RequestFocus
            Return
        End If[/B]
    else if CGlobals.Code=4 Then        '******************************* Jobs
        'Here we create a new Job
        Query = "SELECT * FROM Jobs WHERE Job = ?"
        ResultSet =CGlobals.SQL1.ExecQuery2(Query, Array As String (Text1.Text.ToUpperCase))
        If ResultSet.NextRow = True Then
            'if it exists show a message and do nothing else
            Msgbox2Async(Text1.Text.ToUpperCase & " Already Exists", "Job Exits", "OK", "", "", Null,False)
            Text1.Text=""
            Text1.RequestFocus
            Return
        Else
            'if not, add the entry
            Query = "INSERT INTO Jobs VALUES (?, ?, ?)"
            CGlobals.SQL1.ExecNonQuery2(Query, Array As String(Text1.Text.ToUpperCase, Text2.Text, Text3.Text))
            Msgbox2Async(Text1.Text.ToUpperCase & " Has Been Added", "Job Added", "OK", "", "", Null,False)
            CGlobals.Job=Text1.Text.ToUpperCase
            ExitWorkActions_Click
        End If
        ResultSet.Close
    End If
End Sub
]

Then I list the folders and they are there:

[CODE=b4x][/
Sub ListSites
    Dim list_files As List
   
    If File.Exists(File.DirInternal & "/QESS/","DATA")=False Then
        File.MakeDir(File.DirInternal & "/QESS/", "DATA")
    End If
    list_files=File.ListFiles(File.DirInternal & "/QESS/DATA/")
    ListWork.Clear
    For i= 0 To list_files.Size -1
        If File.IsDirectory(File.DirInternal & "/QESS/DATA/", list_files.Get(i)) = True  Then
            ListWork.Add(list_files.Get(i))
        End If
    Next

End Sub
]

But when I want to add a "Job", under one of the created folders, it tells me that the Folder does not exist.

Here is my code:

[CODE=b4x][/
Sub Checkdatabase
    'Job related
    If File.Exists(File.DirInternal & "/QESS/DATA/", CGlobals.Site)=True Then
        If File.Exists(File.DirInternal & "/QESS/Data/" & CGlobals.Site & "/" , "Jobs.sl3") = False Then
            'if not, initialize it
            CGlobals.SQL1.Initialize(File.DirInternal & "/QESS/Data/" & CGlobals.Site  & "/", "Jobs.sl3", True)
            'and create it
            CreateDataBase
        Else
            'if yes, initialize it
            CGlobals.SQL1.Initialize(File.DirInternal & "/QESS/Data/" & CGlobals.Site & "/", "Jobs.sl3", True)
            If CGlobals.Code>4 Then
                ReadDataBase
            End If
        End If
    End If
End Sub

Sub CreateDataBase
    Query = "CREATE TABLE IF NOT EXISTS Jobs (Job TEXT, Surveyor TEXT, Description TEXT)"
    CGlobals.SQL1.ExecNonQuery(Query)
End Sub
]

Any advise please?
 
Top