Re: [android-developers] Re: Problem computing the free space on the external card - only with a single installation
Hi, I have this same issue; my check evaluates available space as negative in rare cases. I'm not sure yet whether I can take an absolute value. This must be a problem which has happened before. Anyone else come across this? Regards, Julius. On 16/08/2010, at 7:52 AM, Bob Kerns wrote: Two possibilities come to mind. First, perhaps the Dell Streak is one of the phones that has more than one set of SD storage, and mounts the true external one on a subirectory under getExternalStorageDirectory(). But the more likely possibility is that the phone has the problem that this reviewer observed, with the storage sometimes not being seen: http://ptech.allthingsd.com/20100811/dells-streak-a-tiny-tablet-that-takes-calls-too/ That would seem to fit the symptoms better -- sometimes it working, sometimes not. On Aug 15, 12:59 am, Fabrizio Giudici fabrizio.giud...@tidalwave.it wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello. My application allow to download files and store them on the external card. To avoid filling it, I've implemented a safety check so it prevents downloading when the free space is less than 20MB. The computation of the free space is done by: public synchronized long getFreeSpace() { if (statFs == null) { statFs = new StatFs(getExternalStorageDirectory().getAbsolutePath()); } return statFs.getAvailableBlocks() * statFs.getBlockSize(); } which I presume is correct. In fact, it works in all my tests and for what I can say for the 99% of users. But a single user notified me that my app is constantly giving the card full message, as if the above method didn't work. He also told me that the problem went away after a while, and returned after upgrading a new release of my app. The user seems an advanced one, and I think he's able to check and correctly manage the contents of his external card. He reported that the card has more than 1.4GB free on the card. Are you aware of any specific issue or bug? The smartphone of the user is a Dell Streak with Android 1.6. Thanks. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici -www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/ iEYEARECAAYFAkxnnlYACgkQeDweFqgUGxcjjACgqoLP3HiHB5r8lsQytu/59Xdb bE8An1t/mt2gKIdisyZc1sI3/lGHp8dh =dZLt -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Problem computing the free space on the external card - only with a single installation
The code above multiplies two ints and casts them to long. If the intermediate result is over 2Gb, you'll get a negative number. Try multiplying long values instead: long byteCount = blockSize * (long) avlBlocks; -- Kostya Vasilyev -- http://kmansoft.wordpress.com 19.08.2010 0:09 пользователь Julius Spencer jul...@msa.co.nz написал: Hi, I have this same issue; my check evaluates available space as negative in rare cases. I'm not sure yet whether I can take an absolute value. This must be a problem which has happened before. Anyone else come across this? Regards, Julius. On 16/08/2010, at 7:52 AM, Bob Kerns wrote: Two possibilities come to mind. First, perhaps... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Problem computing the free space on the external card - only with a single installation
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/18/10 22:37 , Kostya Vasilyev wrote: The code above multiplies two ints and casts them to long. If the intermediate result is over 2Gb, you'll get a negative number. Try multiplying long values instead: long byteCount = blockSize * (long) avlBlocks; A they are ints Hell. I think it can be definitely that. It is not reproduced on my Droid because it has 5.5Gb free that are reported as 1.5Gb. Indeed, it will report a negative number when the free space is between 2Gb and 4Gb, 6Gb and 8Gb, 10Gb and 12Gb, 14Gb and 18Gb etc... And my user has got 14Gb. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici - www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxsUqwACgkQeDweFqgUGxdJNQCaAwtrwoaj+WMUsL8ZqseowIiw UR0AnixwG7t0M6V9SVhVW/sydNMk0xEw =X1Pt -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Problem computing the free space on the external card - only with a single installation
Oops! Thank you Kostya! On 19/08/2010, at 8:37 AM, Kostya Vasilyev wrote: The code above multiplies two ints and casts them to long. If the intermediate result is over 2Gb, you'll get a negative number. Try multiplying long values instead: long byteCount = blockSize * (long) avlBlocks; -- Kostya Vasilyev -- http://kmansoft.wordpress.com 19.08.2010 0:09 пользователь Julius Spencer jul...@msa.co.nz написал: Hi, I have this same issue; my check evaluates available space as negative in rare cases. I'm not sure yet whether I can take an absolute value. This must be a problem which has happened before. Anyone else come across this? Regards, Julius. On 16/08/2010, at 7:52 AM, Bob Kerns wrote: Two possibilities come to mind. First, perhaps... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Problem computing the free space on the external card - only with a single installation
Two possibilities come to mind. First, perhaps the Dell Streak is one of the phones that has more than one set of SD storage, and mounts the true external one on a subirectory under getExternalStorageDirectory(). But the more likely possibility is that the phone has the problem that this reviewer observed, with the storage sometimes not being seen: http://ptech.allthingsd.com/20100811/dells-streak-a-tiny-tablet-that-takes-calls-too/ That would seem to fit the symptoms better -- sometimes it working, sometimes not. On Aug 15, 12:59 am, Fabrizio Giudici fabrizio.giud...@tidalwave.it wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello. My application allow to download files and store them on the external card. To avoid filling it, I've implemented a safety check so it prevents downloading when the free space is less than 20MB. The computation of the free space is done by: public synchronized long getFreeSpace() { if (statFs == null) { statFs = new StatFs(getExternalStorageDirectory().getAbsolutePath()); } return statFs.getAvailableBlocks() * statFs.getBlockSize(); } which I presume is correct. In fact, it works in all my tests and for what I can say for the 99% of users. But a single user notified me that my app is constantly giving the card full message, as if the above method didn't work. He also told me that the problem went away after a while, and returned after upgrading a new release of my app. The user seems an advanced one, and I think he's able to check and correctly manage the contents of his external card. He reported that the card has more than 1.4GB free on the card. Are you aware of any specific issue or bug? The smartphone of the user is a Dell Streak with Android 1.6. Thanks. - -- Fabrizio Giudici - Java Architect, Project Manager Tidalwave s.a.s. - We make Java work. Everywhere. java.net/blog/fabriziogiudici -www.tidalwave.it/people fabrizio.giud...@tidalwave.it -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org/ iEYEARECAAYFAkxnnlYACgkQeDweFqgUGxcjjACgqoLP3HiHB5r8lsQytu/59Xdb bE8An1t/mt2gKIdisyZc1sI3/lGHp8dh =dZLt -END PGP SIGNATURE- -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en