Good after after uploading my new version to google playstore when i down directly from google play i dont get any problem with the app but those one using the older version when they try to update it flags error of the missing table yet i have already added the tables to the new version that i uploaded is there any way i can solve this . because the user will have to first unstall the old version then download a new version please help
i ahave only added like four table
i ahave only added like four table
B4X:
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Anouncements")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurve")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurveP1P2")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCompare")
query = "CREATE TABLE Anouncements (anounce TEXT,Account TEXT,ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurve ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurveP1P2 ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCompare ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurvePast ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public SQL1 As SQL
Dim SQL1 As SQL
'Dim cursor2 As Cursor
Dim cursor As Cursor
Private nid As Int = 1
Private serializator As B4XSerializator
Dim SQLDataBasePath = File.DirInternal As String
Dim SQLDateBaseName = "studentdbmk.sql" As String
'Dim SQLTabelName = "persons" As String
Public CurrentIndex As Int 'index of the current entry
Public RowNumber As Int 'number of rows
Public rp As RuntimePermissions
Public IDList As List 'list containing the IDs of the database
'we need it because the IDs can be different from the list indexes
'if we delete an entry its ID is lost
Dim cursor As Cursor
'Variables for Edit
'the Edit Activity has two modes "Add" and "Edit"
Public EditMode As String
'Variables for Filter
'variable for the filter query,
'defined in the btnFilter_Click routine
'and will be used In the DBWebView ShowTable routine
Public FilterQuery As String
'flag for the filter active or inactive
Public flagFilterActive As Boolean
'Boolean operator used in the filter
'can be OR or AND
Public FilterBooleanOperator As String
'Variables used to hold the selected indexes of the Spinners
Public SelectedFirstName = 0 As Int
Public SelectedLastName = 0 As Int
Public SelectedCity = 0 As Int
Dim strTitle As String
Dim strBody As String
End Sub
Private Sub CreateMessage(Body As String) As Byte()
Dim m As Message
m.Initialize
m.Body = Body
m.From = "currentName"
Return serializator.ConvertObjectToBytes(m)
End Sub
Public Sub SendMessage(Body As String)
CreateMessage(Body)
'client.Publish2("all", CreateMessage(Body), 0, False)
End Sub
Sub Service_Create
'initialize the variables
CurrentIndex = -1
RowNumber = 0
EditMode = "Add"
FilterQuery = ""
flagFilterActive = False
FilterBooleanOperator = "OR "
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
'File.Delete(File.DirInternal, "studentdbm.sql") ' only for testing, removes the database
'check if the database already exists
If File.Exists(SQLDataBasePath, SQLDateBaseName) = False Then
'copy the default DB
File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
'if not, initialize it
SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, True)
'and create it
'CreateDataBase
SQLInit
'CallSubDelayed(Firebasemessaging, "0782911364")
'cursor.IsInitialized
'SQLInit
CallSubDelayed(Firebasemessaging, "SubscribeToTopics")
Else
SQL1.Initialize(SQLDataBasePath, SQLDateBaseName, True)
'SQLInit
CallSubDelayed(Firebasemessaging, "SubscribeToTopics")
' Dim SQLQry As String = "DELETE FROM Allacounts"
'SQL1.ExecNonQuery("DELETE FROM Register")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurve")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurveP1P2")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCompare")
'Private query As String
' query = "CREATE TABLE AcademicsLoadCurve ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
'SQL1.ExecNonQuery(query)
'
'query = "CREATE TABLE AcademicsLoadCurveP1P2 ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
'query = "CREATE TABLE AcademicsLoadCompare ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Anouncements (anounce TEXT,Account TEXT,ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE SMSlist (Account Text, Names Text,Phone text,Sex text,ID INTEGER,Phone2 text )"
'SQL1.ExecNonQuery(query)
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS Register")
'query = "CREATE TABLE Register (Code Text, Phone Text, Email Text, Sex Text, ID INTEGER)"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Academics ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Balances (Account Text,Names text, Class text,Stream text,Amount NUMERIC, ID INTEGER,Phone Text )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Alevelreport (Account Text, Points Text,Name text,Subject text, ID INTEGER )"
'SQL1.ExecNonQuery(query)
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS Terms ")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS SMSlist")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS Recievedsms")
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS Studentphoto2")
'query = "CREATE TABLE Academicspast ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Statement (Account Text,Names text,DESCRIPT text,DEBITAMNT text,CREDITAMNT text, TREF text,TRDATE nvarchar(50),BAL text)"
'SQL1.ExecNonQuery(query)
'SQL1.ExecNonQuery("DROP TABLE IF EXISTS Register")
'query = "CREATE TABLE Register (Code Text, Phone Text, Email Text, Sex Text, ID INTEGER)"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Recievedsms (Daterecieved Text, Sms text,ID INTEGER)"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE SMSlist (Account Text, Names Text,Phone text,Sex, ID INTEGER )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Eventsinfo (Events TEXT, Class TEXT,Stream TEXT, Dates TEXT,Tcode TEXT, Id INTEGER Not Null PRIMARY KEY AUTOINCREMENT UNIQUE,Term TEXT,Years TEXT)"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Years (Years Text,ID INTEGER )"
'SQL1.ExecNonQuery(query)
'query = "CREATE TABLE Studentphoto2 (name TEXT, image BLOB,Account TEXT)"
'SQL1.ExecNonQuery(query)
' query = "CREATE TABLE Terms (Term Text,Account Text,ID INTEGER )"
' SQL1.ExecNonQuery(query)
End If
End Sub
Sub SQLInit
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Register")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Alevelreport")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Anouncements")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurve")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCurveP1P2")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS AcademicsLoadCompare")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Academicspast")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Classes")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Years")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Terms")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Sentmessages")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Recievedsms")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS SMSlist")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Student")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Eventsinfo ")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Academics")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Allacounts")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Balances")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Statement")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Balances2")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Studentphoto")
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Studentphoto2")
Private query As String
'SECONDARY
SQL1.ExecNonQuery("DROP TABLE IF EXISTS Classes")
query = "CREATE TABLE Classes (Class Text, ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S1', '1')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S2', '2')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S3', '3')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S4', '4')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S5', '5')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('S6', '6')"
'PRIMARY
query = "INSERT INTO Classes VALUES ('PRE', '11')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P1', '12')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P2', 13)"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P3', '14')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P4', '15')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P5', '16')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P6', '17')"
SQL1.ExecNonQuery(query)
query = "INSERT INTO Classes VALUES ('P7', '18')"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Studentphoto2 (name TEXT, image BLOB,Account TEXT)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Anouncements (anounce TEXT,Account TEXT,ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE SMSlist (Account Text, Names Text,Phone text,Sex text,ID INTEGER,Phone2 text )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Years (Years Text,ID INTEGER )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Terms (Term Text,Account Text,ID INTEGER )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Alevelreport (Account Text, Points Text,Name text,Subject text, ID INTEGER )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Sentmessages (Datesent Text, Sms text,ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Recievedsms (Daterecieved Text, Sms text,ID INTEGER)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Student ( Account TEXT, Names TEXT, Class TEXT, Stream TEXT, Amount REAL, Dates TEXT, id INTEGER Not Null PRIMARY KEY AUTOINCREMENT UNIQUE, Years TEXT, Term TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Register (Code Text, Phone Text, Email Text, Sex Text, ID INTEGER)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Allacounts (Account Text, Phone text, ID INTEGER )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Balances (Account Text,Names text, Class text,Stream text,Amount NUMERIC, ID INTEGER,Phone Text )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Balances2 (Account Text,Names text, Class text,Stream text,Amount REAL, ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE)"
SQL1.ExecNonQuery(query)
'query = "CREATE VIEW Singlebal AS Select Balances.Amount FROM Balances INNER JOIN Allacounts ON Balances.Account = Allacounts.Account "
'SQL1.ExecNonQuery(query)
query = "CREATE TABLE Eventsinfo (Events TEXT, Class TEXT,Stream TEXT, Dates TEXT,Tcode TEXT, Id INTEGER Not Null PRIMARY KEY AUTOINCREMENT UNIQUE,Term TEXT,Years TEXT)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Academics ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Academicspast ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Statement (Account Text,Names text,DESCRIPT text,DEBITAMNT text,CREDITAMNT text, TREF text,TRDATE nvarchar(50),BAL text)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE Studentphoto (Account Text,Names text, Class text,Stream text,image BLOB)"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurve ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurveP1P2 ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCompare ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
query = "CREATE TABLE AcademicsLoadCurvePast ( Names TEXT, Class TEXT, Stream TEXT, Subject TEXT, Total NUMERIC, Grade TEXT, Mid NUMERIC,Ends NUMERIC,Term TEXT, Years TEXT, id INTEGER,Phone TEXT )"
SQL1.ExecNonQuery(query)
End Sub
Sub Service_Start (StartingIntent As Intent)
cursor = SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
If cursor.RowCount > 0 Then
cursor.Position =0
Dim Phonet As String
Phonet = cursor.Getstring("Phone")
Dim sx As String
sx = cursor.Getstring("Sex")
' sx = "Father"
End If
Dim CustID As String = Phonet' Customer ID
Dim jtk As HttpJob
jtk.Initialize("", Me)
'j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVB.ashx?customerid=" & CustID)
jtk.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
'jtk.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
'jtk.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (jtk) JobDone(jtk As HttpJob)
If jtk.Success Then ' if job is success (http status code 200)
Dim RetVal As String
Log(RetVal)
RetVal = jtk.GetString
If jtk.GetString = "[]" Then
'Msgbox("Please try Again ","SMIS")
'Return
Else
Dim jpt As JSONParser
jpt.Initialize(jtk.GetString)
'Log(jpt) ' will pr
Log($"Token(${jpt})"$)
Dim quotes As List = jpt.NextArray
For Each quot As Map In quotes
Log("Account: " & quot.Get("Account"))
Log("sms: " & quot.Get("sms"))
Log("Datesent: " & quot.Get("Datesent"))
Service.StartForeground(nid, CreateNotification(quot.Get("sms")))
StartServiceAt(Me, DateTime.Now + 60 * DateTime.TicksPerMinute, True)
'CancelScheduledService(Me)
Next
End If
End If
End Sub
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_HIGH)
notification.Icon = "icon"
notification.SetInfo("Kabojja Junior School", Body, Sendsms)
Return notification
End Sub
Sub Service_Destroy
End Sub