Sub Process_Globals
'YT
Public NextPageToken As String
Public out As OutputStream
'DB
Dim VIDEODB As SQL
End Sub
Sub Service_Create
'DB
File.Delete(File.DirDefaultExternal, "videos.db") ' only for testing, removes the database
File.Delete(File.DirInternal, "videos.db")
'check if the database already exists
If File.Exists(File.DirDefaultExternal, "videos.db") = False Then
'copy the default DB
File.Copy(File.DirAssets, "videos.db", File.DirDefaultExternal, "videos.db")
'if not, initialize it
VIDEODB.Initialize(File.DirDefaultExternal, "videos.db", True)
'and create it
'CreateDataBase
'copy the default DB
File.Copy(File.DirAssets, "videos.db", File.DirDefaultExternal, "videos.db")
Else
'if yes, initialize it
VIDEODB.Initialize(File.DirDefaultExternal, "videos.db", True)
End If
End Sub
Private Sub YTimgRequest(imgurl As String)
Dim URLtoGET As String = imgurl
Log(URLtoGET)
Dim J As HttpJob
J.Initialize("JobImageDownload", Me)
J.Download (URLtoGET)
J.GetRequest.SetHeader("Connection", "Keep-Alive")
Log("Downloading Image")
End Sub
Sub JobDone (Job As HttpJob)
Dim JobResult As String
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True And Job.JobName = "JobImageDownload" Then
JobResult = Job.GetString
File.Copy2(Job.GetInputStream, out)
out.close
Job.Release
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub