0

Is is possible to check the remaining storage within my sqlite db using phonegap?

I've created a db and defined the size at 10MB.

db = window.openDatabase("SampleDB","0.1","Name DB", 10000000);

What I want to do is notify the client prior to adding a record through a form on a phonegap app that the DB size has been exceeded so they can't enter any more records. I'll be syncing up with a server when I have a connection to clear down the db

Is this possible as I don't want to create a 100MB DB and hope the size isn't maxed out before a connection is found to the server?

Thanks.

1 Answers1

0

Informative list of all saving approaches and their memory-limitations in cordova can be found here.

But when you really want to know how much memory a db can hold of an individually device you do not get around the work to modify a plugin for all concerning platforms.

At the moment there are still only two global players on mobile market:

Android:

But there is a way to get max memory usage of a sqlite-db of android here

Have a look on the answer that states: Android's SQLiteDatabase class includes a method that sets a maximum database size, setMaximumSize(long numBytes)

I made a plugin for android recently and so I'm pretty confidend that making an android db-max-checker-plugin is a peace of cake. Of course you have to implement code that handles sqlite-db operations on your own but there are tons of tutorials out there.

And here is some kind of startup app for IOS, Android and WindowsPhone(Hello World).

IOS(Apple):

Unfortunate I've not found any reference that matches your request but here is a good note that states that sqlite-db is limit only on hard-drive of your device and the programm's footprint(how much objects are allocated, imported resources like images etc.) is rather moderate. In terms of cordova allocating a great deal of objects is no need. Nowadays an IOS-device comes with a big hard-drive space so the chance that there is a memory-shortage sometime is less likely than when it comes to android.

Community
  • 1
  • 1
Blauharley
  • 4,186
  • 6
  • 28
  • 47