Android Question [SOLVED]How To Change the KeyValueStore values or delete the file completly?

Daniel44

Active Member
Licensed User
Hey everyone!

Well, Im on a project using KeyValueStore v. 2.30 and inside I have a method that creates a file with values within that project. Then I've created a method that reads those values. What I need it's delete that values or change them or if it is possible delete the whole file while the app is running in order when the app initialize again that file doesn't exist.. I don't know if it's possible.

Here my method to create file

B4X:
Sub FileCreated
    kvs.Initialize(File.DirInternal, FILETOENCRIPT)
    kvs.Put(VALOR1, VALOR2)
    Log("EL VALOR DEL INDICE ES: " & VALOR2)
End Sub

and here's I'm trying to delete or change it

B4X:
kvs.DeleteAll
   
    kvs.GetDefault(DEL1, DEL2)'DEL1 AND DEL2 ARE ANOTHER VALUES TO CHANGE OLD VALUES'
    Log(kvs.Get(DEL2))
     'here are my attempts to delete or change the values of the file but nothing works
    'kvs.deleteAll'
'    File.Delete(File.DirInternal, FILETOENCRIPT)
'    kvs.Initialize(File.DirInternal, FILETOENCRIPT)
'    kvs.Remove(VALOR1)


Notice: The attempts to delete the whole file or change its values are called from a button

Thanks
 
Last edited:

Daniel44

Active Member
Licensed User
It is solved with this:

B4X:
kvs.Close
    File.Delete(File.DirInternal, FILETOENCRIPT)

With this I've deleted the file.
Thank you
 
Upvote 0
Top