×

Discussion Board

Results 1 to 13 of 13

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Question Handle low storage space condition

    Hi All,

    I want to handle low storage space condition(isolated storage not ram memory) in my application. So if this case happens do i get some notification from system? Or do i need to set up a timer to check this every now and then myself. Searching for this i got only about handling low ram memory conditions. Please help

    Regards

  2. #2
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    297

    Re: Handle low storage space condition

    Hello Kunal as far as I know, there is IsolatedStorageFile.GetUserStoreForApplication().AvailableFreeSpace which return the available space on the phone, and
    IsolatedStorageFile.GetUserStoreForApplication().IncreaseQuotaTo()
    which helps increase the quota allowed (returns a bool, true if increased else it returns false)

  3. #3
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Re: Handle low storage space condition

    Hi Loukt,

    So i need to check and handle these conditions by myself using timer or some other logic right.? System will not convey me by raising some event when IsolatedStorageFile.GetUserStoreForApplication().AvailableFreeSpace becomes low.

    Regards

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    297

    Re: Handle low storage space condition

    Quote Originally Posted by Kunal Prime View Post
    Hi Loukt,

    So i need to check and handle these conditions by myself using timer or some other logic right.? System will not convey me by raising some event when IsolatedStorageFile.GetUserStoreForApplication().AvailableFreeSpace becomes low.

    Regards
    Hello Kunal,

    not necessary a timer, but each time you want to write on the IsolatedStorageFile

    use this snippet to check if there is enough disk space, (I think neededSpace needs to be the byte value, as for 1Mb => 1*1024*1024 bytes )
    Code:
    public void CheckDiskSpace(long neededSpace)
    {
        using (IsolatedStorageFile myISFile = IsolatedStorageFile.GetUserStoreForApplication())
        {
            if (myISFile.AvailableFreeSpace > neededSpace)
            {
                if (!myISFile.IncreaseQuotaTo(myISFile.Quota + neededSpace)) // newSpace = oldSpace(myISFile.Quota) + neededSpace
                {
                    throw new Exception("No space available on the phone, please delete a file");
                }
            }
        }
    }
    I've just wrote it and didn't test it yet, you can run it and give us feedback.

    Yassine,
    Last edited by Loukt; 2013-03-12 at 11:28.

  5. #5
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Re: Handle low storage space condition

    Hi Yassine,

    Thanks, will test this snippet and let you know.

    Regards

  6. #6
    Registered User
    Join Date
    Mar 2013
    Location
    Goa, India
    Posts
    32

    Re: Handle low storage space condition

    Hi Yassine,

    Used below code
    using (IsolatedStorageFile myISFile = IsolatedStorageFile.GetUserStoreForApplication())
    {
    if (myISFile.AvailableFreeSpace < neededSpace)
    {
    long newSpace = myISFile.Quota + 10485760L;
    if (!myISFile.IncreaseQuotaTo(newSpace))
    {
    throw new Exception("No space available on the phone, please delete a file");
    }
    else
    {
    Debug.WriteLine(myISFile.Quota);
    }
    }
    }

    But it throws me below exception.

    {System.ArgumentException: The new quota must be larger than the old quota.
    at System.IO.IsolatedStorage.IsolatedStorageFile.IncreaseQuotaTo(Int64 newQuotaSize)
    at SharedCode.IsolatedStorageAccess.FileStore.CheckDiskSpace(Int64 neededSpace)
    at Marketplace.LandingPage..ctor()} System.Exception {System.ArgumentException}
    While debugging i found myISFile.Quota returns 9223372036854775807 which is the maximum possible value for a signed long. So when we add anything to it appends a minus sign to indicate a bigger number. So initially myISFile.Quota = 9223372036854775807 and after adding 10MB, newSpace = -9223372036844290049. Which myISFile.IncreaseQuotaTo considers less than earlier quota and throws the exception. :P

    Any thoughts or suggestions on this.??

    And sorry i don't know how to embed code in reply so putting them in [QUOTE] tags.

    Regards
    Last edited by Kunal Prime; 2013-03-12 at 09:10.

Similar Threads

  1. Replies: 5
    Last Post: 2010-05-09, 22:32
  2. Storage space and processing a MIDLET??
    By quoctrang in forum Mobile Java General
    Replies: 6
    Last Post: 2009-01-13, 04:21
  3. Sent items (Storage space)
    By Gian82 in forum General Development Questions
    Replies: 1
    Last Post: 2008-11-28, 16:49
  4. Replies: 4
    Last Post: 2008-09-03, 16:11
  5. Hoow to handle low memory condition ?
    By chirag_cel in forum Symbian
    Replies: 3
    Last Post: 2007-12-29, 08:23

Posting Permissions

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