Android Question How to keep KVS class alive during app execution?

Mashiane

Expert
Licensed User
Longtime User
Hi there

I'm using the kvs class in my project. I'm able to save and retrieve records however after an hour of inactivity in my app and the app resumes, the kvs cannot be read and raises an error of CantOpenDatabase: specified directory or database does not exist.

The database path is declared as a variable in a module. I have updated the class to include this method..

B4X:
private Sub CheckOpen
    If sql1.IsInitialized = False Then
        Initialize(MasterDir,MasterFile)
    End If
End Sub

This method is supposed to test if the db is still alive and if not initializes it, however the Initialize call does not compile. I'm still baffled as to why is this. It says it expects a "," but that is there already.

Perhaps I'm missing something.. Can someone please advise me here..
 

Attachments

  • KeyValueStore.bas
    7 KB · Views: 156

Mashiane

Expert
Licensed User
Longtime User
This is exactly the purpose of the Starter service.

kvs should be a process global variable in the Starter service and it should be initialized in Service_Create sub.
Why is it that I cannot call the Initialize method inside another method within then same class as in my CheckOpen method above? The ide is giving me an error.
 
Upvote 0
Top