Android Question Huawei and SQLite

Declan

Well-Known Member
Licensed User
Longtime User
My app makes use of a local (on device) SQLite database/tables.
All works well with all makes of phones, but not on Huawei phones.
On Huawei, I can write to the SQLite table and query the tables.
However, when I Delete a record within a table on a Huawei device, it does not Delete the correct record.
I use: Starter.DB.ExecNonQuery("DELETE FROM myleads WHERE id = " & MyID) to Delete the record.
MyID is the unique record ID (obtained from the remote MySQL database table).
Something seems dodgy....
My code snippet:
B4X:
Sub btnMyLeadsDelete_Click
    Dim Index As Int = clv2.GetItemFromView(Sender)
    Dim text As String = expandable.GetValue(Index)
    Log(text)

    Dim MyID As String = txtID.text
    MyID = MyID.Trim
    Starter.DB.ExecNonQuery("DELETE  FROM myleads WHERE id = "  & MyID)
    
    Log("LEAD DELETED: " & MyID)
    ToastMessageShow("LEAD HAS BEEN DELETED", False)
    CallSubDelayed(Me, "loadMyLeads")
End Sub

Above works on all phones, EXCEPT HUAWEI
 

DonManfred

Expert
Licensed User
Longtime User
Is id a autoincrement field of this table?
If yes then it may not have the same id as the remote mysql table field.
Try to add the unique id field from the mysql db to a new field in the sqlite db when exporting the remotedb to sqlite. idremote for ex.
Use this reference then to later delete a record based on the idremote

I don´t think this is a Huawai (or any other device manufacturer) problem. I expect the problem is somewhere else.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Is id a autoincrement field of this table?
No, the id is obtained from the remote MySQL table.
The SQLite table column is "id"
The id from the remote MySQL table is then written into the local SQLite table field "id".
I do not Delete the record from the remote MySQL table - only delete from the local SQLite table.

I don´t think this is a Huawei (or any other device manufacturer) problem. I expect the problem is somewhere else.
It is very strange that on all devices, other than Huawei, I have no problem deleting the record from the local SQLite table.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
One thing I did not mention:
The data received from the remote MySQL table is in the form of a Firebase message.
This Firebase message is then received by the phone, message is parsed and fields written to the local SQLite table.
Could it possibly be that Huawei handles Firebase messages differently to other devices?
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Also Huawei devices from September 2019 do not have Play Services. Firebase will not work on these devices.
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Yes.
 
Upvote 0
Top