- How to find the amount of free storage (disk space) left on Android? [duplicate]
- 10 Answers 10
- How to increase storage for Android Emulator? (INSTALL_FAILED_INSUFFICIENT_STORAGE)
- 22 Answers 22
- Update
- Original Eclipse-based Answer
- How to Check available space on android device ? on SD card? [duplicate]
- 9 Answers 9
- The above code has reference to some deprecated functions as of August 13, 2014. I below reproduce an updated version:
- Update:
- Low disk space on android mystery
- Android low on space
- 2 Answers 2
- Why can’t I use the free space available at /system ?
- Why is there so little space at /data ?
- What can be done?
How to find the amount of free storage (disk space) left on Android? [duplicate]
I am trying to figure out the available disk space on the Android phone running my application. Is there a way to do this programmatically?
10 Answers 10
Example: Getting human readable size like 1 Gb
String memory = bytesToHuman(totalMemory())
Converting bytes to human readable format (like 1 Mb, 1 Gb)
Try StatFs.getAvailableBlocks. You’ll need to convert the block count to KB with getBlockSize.
There are some subtleties regarding paths that none of the current answers address. You must use the right path based on what kind of stats you are interested in. Based on a deep dive into DeviceStorageMonitorService.java which generates the low disk space warnings in the notification area and the sticky broadcasts for ACTION_DEVICE_STORAGE_LOW, here are some of the paths that you can use:
To check free internal disk space use the data directory obtained via Environment.getDataDirectory(). This will get you the free space on the data partition. The data partition hosts all the internal storage for all apps on the device.
To check free external (SDCARD) disk space use the external storage directory obtained via Environment.getExternalStorageDirectory(). This will get you the free space on the SDCARD.
To check for available memory on the system partition which contains OS files, use Environment.getRootDirectory(). Since your app has no access to the system partition, this stat is probably not very useful. DeviceStorageMonitorService uses for informational purposes and enters it into a log.
To check for temporary files / cache memory, use Environment.getDownloadCacheDirectory(). DeviceStorageMonitorService attempts to clean some of the temporary files when memory gets low.
Some sample code for getting the internal (/data), external (/sdcard) and OS (/system) free memory:
Источник
How to increase storage for Android Emulator? (INSTALL_FAILED_INSUFFICIENT_STORAGE)
I get this sometimes(not often) for one of my projects, couple of classes only
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
How do I increase emulator’s storage?
22 Answers 22
Update
This answer is, as I write this, nearly eight years old, and about five years stale. But it’s still (as I write this) the «accepted» answer, because it answered the question when it was asked.
The newer answer, that applies to the newer Android Studio tools, can be found here: https://stackoverflow.com/a/35828035/62 — it’s a great answer with screen shots. If you’re using Android Studio, ignore the Eclipse answer below.
Original Eclipse-based Answer
I was searching for the answer to this question, and was unsatisfied with the above answers. But then I found the answer, so here it is for future reference:
To summarize (and clarify), in Eclipse, go to «Debug Configurations». You can find that in the drop-down under the «debug» icon. Select «target», and select a preferred emulator target to launch. Then under «additional emulator command line options,» add this:
-partition-size 1024
Then CLOSE the emulator (and remove any devices), and click the debug icon, which will launch the preferred emulator you selected. This is important: Eclipse needs to launch the debugger, not AVD.
Источник
How to Check available space on android device ? on SD card? [duplicate]
How do I check to see how much MB or GB is left on the android device ? I am using JAVA and android SDK 2.0.1.
Is there any system service that would expose something like this ?
9 Answers 9
Yaroslav’s answer will give the size of the SD card, not the available space. StatFs’s getAvailableBlocks() will return the number of blocks that are still accessible to normal programs. Here is the function I am using:
The above code has reference to some deprecated functions as of August 13, 2014. I below reproduce an updated version:
Update:
getBlockCount() — return size of SD card;
getAvailableBlocks() — return the number of blocks that are still accessible to normal programs (thanks Joe)
I have designed some ready to use functions to get available space in different units. You can use these methods by simply copying any one of them into your project.
Based on this answer, Added support to Android version
New methods was introduced since API version 18.
I used something like that for big disk cache size estimation (for Picasso OkHttp downloader cache). Helper method was like that:
also , if you want to check available space on internal memory , use:
Google has information on this on the getting started page — See Query Free Space. They say that you can either check the available space by getFreeSpace() but they state that this is inaccurate and you should expect a little less free space than this. They say:
If the number returned is a few MB more than the size of the data you want to save, or if the file system is less than 90% full, then it’s probably safe to proceed. Otherwise, you probably shouldn’t write to storage.
Also they give the advice that it’s often more useful not the check the free space at all and just try catch for an error:
You aren’t required to check the amount of available space before you save your file. You can instead try writing the file right away, then catch an IOException if one occurs. You may need to do this if you don’t know exactly how much space you need. For example, if you change the file’s encoding before you save it by converting a PNG image to JPEG, you won’t know the file’s size beforehand.
I would recommend that only for very large file sizes you should check the available storage beforehand so you don’t lose time downloading or creating a file which if obviously too large to hold. In either cases you should always use try catch so I think that the only argument for checking the available free space beforehand if is either the unnecessary use of resources and time is too much.
Источник
Low disk space on android mystery
I have a Samsung galaxy note 3 with 32gb internal storage (available 25.98GB for storage after system use) and 64gb sdcard (available 59.46GB after formatting).
But I am finding out that the data is mysteriously gone. The problem seems to be with the internal storage (32gb) and not the sdcard (64gb)
I have tried to enclose the screen shots for the top level for both sdcard and internal storage. As you can see the sdcard is using 56.02GB and the drives app (or the settings screen) shows the usage of each directory correctly. The same is true using any file explorer or other apps.
But for the internal storage, I am lost. From the available 25.98gb about 1.75gb is free and 24.23 gb is used. But directories are using only 14.24gb. I have also tried to include the directory list for your reference and the top directories only adds up to 14 gb. Where has 10 gb vanished? I assume that the system is using it somehow, but no idea where
P.S. I posted this in the Q&A section but could not post the screenshots. I am using the Drives app by Potapovich, Anton for this data.
Attached Thumbnails
Источник
Android low on space
I know this question is quite common, but nothing I’ve read so far really helped me. I have a Samsung Galaxy Mini, and had a similar problem with the stock ROM. For some other reasons, I’ve rooted it and put Cyanogenmod 7 on it. Everything works quite well, but the free space is just eating itself. All my applications are sent to SD card (except facebook, which runs exceptionally slow when on card). And still, I’m only left with 6MB of free internal space. I’ve cleaned up my SMS messages and browser caches, nothing really helps. I’m showing my storage analysis. The thing that bugs me are the /system and /data partitions. How come that /system has so much empty space, while /data has so little. Isn’t it supposed to be a compact partition?
As for applications, I really don’t have a lot, except regular GMail, Google Maps and such. Just Opera browser, iGo, Adobe Reader, Outlook and a few apps with less then 1MB.
P.S While taking the screenshot, the Storage Analyser is showing 18MB free, But the system is showing 9MB. Nevertheless, both are not enough for normal work.
2 Answers 2
First a little explanation on the storage (you might also check the tag wiki of the storage tag for a short introduction):
Why can’t I use the free space available at /system ?
The /system partition holds the often so-called «ROM», i.e. the Android core system (including the pre-installed apps, see bloatware). By default, it is mounted read-only for several reasons (including «security», so no app can tamper with anything here — and the user cannot accidentally render the system unusable). This is also why a factory reset will present you with a «virgin system»: it will not touch this read-only partition.
Being mounted read-only makes it clear you cannot write things onto this partition — which answers the question why you cannot make use of the «free space» it has. You might wonder why a read-only partition then is not «sized appropriately» — but it is: it just takes into consideration that additional space might be needed for a system update. Future Android versions might (and most likely will) need more space, also providers might want to add more bloatware.
Why is there so little space at /data ?
To put it in simple words: 180MB is all that was left after taking away the
200MB for /system . The Galaxy Mini S5570 isn’t a high-end device. And before you ask: No there’s nothing you can do to increase the amount of overall storage available to /data (at least nothing easy — though some geeks might think of creating a bigger partition on the SDCard and mount it as /data , this is nothing simple and also not without side-effects).
What can be done?
Nothing much. If your device is rooted, you could think of using a bigger SDCard (your device supports up to 32GB), and moving stuff over there with things like link2sd or even Data2SD. You can regularly clear your apps’ caches and do some other cleanup. Or you can simply go for a new device which offers more storage (and more RAM, and a faster CPU).
I know it’s not very satisfying that a device, just being 2 years old (the S5570 was released to the market in February 2011) already is unable to keep up with daily needs. But unfortunately, 180MB storage (and 384MB RAM) really is not much to play around. So all that currently remains is to refer you to the most faqs of the «insufficient storage» tag to find a solution until you can get yourself a new device. See especially:
Источник