Get a Jumpstart with our Sample Apps
Results 1 to 2 of 2

Thread: How to know the size of the data in Local storage?

  1. #1
    Member
    Real Name
    Paul Ammoun
    Join Date
    Oct 2012
    Location
    Beirut, Lebanon
    Posts
    194

    Default How to know the size of the data in Local storage?

    Hi,
    I know local storage has a maximum size of 5mb :(
    How to know if this size is exceed?
    what happens if the 5 mb get exceeded?
    Last question : is using local storage a reliable way of building disconnected apps?

    Thank you all and have a nice sunday

    Paul

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,384

    Default Re: How to know the size of the data in Local storage?

    Lots of information out there about this.

    I found this site...

    Code:
    http://jamescroft.co.uk/blog/webdev/create-remaining-storage-bar-html5-localstorage/
    which contained this line of code...

    Code:
    var storage = 1024 * 1024 * 5 - unescape(encodeURIComponent(JSON.stringify(localStorage))).length;
    But... if you're building a disconnected app, then you'll be using PGB, which means you don't have to worry about localStorage. You'll be using the device file system storage which can include writing directly to storage, using a SQLite databases, or a NoSQL database.

    And the answer to your question is... no... localStorage is not a realiable way to store data for a disconnected app.

Similar Threads

  1. How to persist to local storage a lookup data?
    By JetLi in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 06-17-2016, 01:00 PM
  2. delete local storage
    By jhaytko in forum Mobile & Browser Applications
    Replies: 10
    Last Post: 04-23-2015, 08:36 PM
  3. Image from local storage
    By I-windo in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 02-25-2015, 06:16 AM
  4. Local storage question
    By simonjm in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 02-03-2015, 10:17 PM
  5. Restore List Data from Local Storage
    By jhaytko in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 01-23-2015, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •