Android Question Don't update my SQL database, but create new temporary files

Fab117

Member
Licensed User
Longtime User
Hello,
I'm trying to update an app developed in 2016.

Today issue: I collect data's that need to be added into my local database. Issue is that instead adding the data's into the local data base, it creates a new temporary file
SQL1.png



NB: I want my app to save files into "File.DirRootExternal" => in the manifest, I have "<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>" and I'm clear that my app will never be shared on Google Play.

The was I proceed:
'In starter
Public SQL1 As SQL
Public NomBaseDeDonnees As String : NomBaseDeDonnees = "InventaireLogement.db"
Public NomBaseDeDonneesDeSupport As String : NomBaseDeDonneesDeSupport = "InventaireLogement.db"
'Reference database is stored in DirAsset
In main, I create all folders and subfolders needed
As example:
If File.Exists(Starter.EmplacementStockageSurDevice & Starter.RepertoireRacine & Starter.NomApplication & "/Data Base", "") = False Then
File.MakeDir(Starter.EmplacementStockageSurDevice, Starter.RepertoireRacine & Starter.NomApplication & "/Data Base")
End If
In main, I copy my database from DirAsset (if needed) and initialize the database
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
If File.Exists(Starter.RepertoireStockageBaseDeDonnees, Starter.NomBaseDeDonnees) = False Then
File.Copy(Starter.RepertoireStockageBaseDeDonneesDeSupport, Starter.NomBaseDeDonneesDeSupport, Starter.RepertoireStockageBaseDeDonnees, Starter.NomBaseDeDonnees)
Starter.SQL1.Initialize(Starter.RepertoireStockageBaseDeDonnees, Starter.NomBaseDeDonnees, True)
Else
Starter.SQL1.Initialize(Starter.RepertoireStockageBaseDeDonnees, Starter.NomBaseDeDonnees, True)
End If
End If
In another activity module (AjoutEdit), I collect all my data's into several variables and try to add them in my database
Starter.SQL1.ExecNonQuery2("INSERT INTO Inventaire VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", _
Array As Object(PieceSelectionnee_rowID, DescriptionDeLObjet, MarqueDeLObjet, ModelDeLObjet, CategorieSelectionnee_rowID, DateDAchatDeLObjet, LieuDAchatDeLObjet, PrixDeLObjet, PhotoTaken(0), PhotoTaken(1), PhotoTaken(2), PhotoTaken(3), PhotoTaken(4), Starter.CodeBarre))

Would someone know what is wrong ?

Main difference vs my 2016 app version is that database transfer from Dir Asset to the device is done in "Main" instead "Starter" (link).

Have a nice week-end

Fab
 

MicroDrie

Well-Known Member
Licensed User
I see the following three files which are related to the so-called WAL mode for multi-access the database file:
  1. The main database file with an arbitrary name "X".
  2. The write-ahead log file, usually named "X-wal".
  3. The wal-index file, usually named "X-shm"\\
If the last user close the database the last 2 files will "merged" into the first one and disappear. So the database is still in use or if not, is not correctly closed by all database users or your program didn't close the database at some point after open it.
 
Upvote 0
Top