B4J Library [B4X] KVS2 / KeyValueStore 2 - Simple & Powerful Local Datastore

Status
Not open for further replies.

ilan

Expert
Licensed User
Longtime User
hi

i have 2 questions related to KVS please

1) when i remove entries or delete all entries from the database the file size does not change.
so if the database had 10 entries including images and was 10mb after deleting everything from the database the db file has the same size, why?

B4X:
database.DeleteAll

B4X:
Public Sub DeleteAll
    sql1.ExecNonQuery("DROP TABLE main")
    CreateTable
End Sub

2) when i put an image to the database with the size of 60kb the file size is much bigger (about 214kb) why?

i user:

B4X:
    Dim out As OutputStream
    out.InitializeToBytesArray(0)
    Value.WriteToStream(out)
    Put(Key, out.ToBytesArray)
    out.Close

thanx
 
Last edited:

ilan

Expert
Licensed User
Longtime User
ok for the first question i have the answer

B4X:
sql1.ExecNonQuery("VACUUM")

but not for the second. if i put an image with size 61KB why do my database file size increase to 214kb ?
 

rboeck

Well-Known Member
Licensed User
Longtime User
I think its a normal database function; internaly the often use pages; so sometime for one record a new page is used and the database size increases. With next insert the database size is possible the same. The database try to optimize for speed and not for space, you see it cleary, that zipping databases has the most effect.
 

ilan

Expert
Licensed User
Longtime User

1.6 mb images made a db file of 14 mb
 

OliverA

Expert
Licensed User
Longtime User
Yes but how do you declare and initialize it since B4J does not have a starter service.
See attached. Please read the notes in the main file.
 

Attachments

  • b4j_kvs_example_nonui.zip
    3 KB · Views: 567

Ricky D

Well-Known Member
Licensed User
Longtime User
Thanks Erel. I just came across this and it's excellent
 

asubias

Member
Licensed User
Hi, I get this error with the function getEncrypted
B4X:
javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT

The stored data is an IP address

Thank you in advance
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…