14
Posted by alex on Nov 24th, 2014

android-logo-298x300-1.jpgAndroid reserves a certain percentage of the data partition for itself to make sure apps won't run out of working space (Receiving SMS, emails, call logs, etc). On phones with no external storage it means that when you are down to 10% free OR 500MB (whichever is smaller) you won't be able to update/install anything, even if it's only a couple kilobytes. It's really annoying for devices with 4-8GB to lose 500MB like that.
 

IMPORTANT: If you have plenty of space available and yet have the insufficient storage error, you should look elsewhere to fix your issue. The following guide is only to reclaim the 10% remaining, not fix Play Store issues. The procedure should work with any Android 4.x, but it was tested only on stock Moto G and LG G1.

How to

Before starting you need to choose how much space you wish to reserve for Android. You can choose a percentage, a size, or both (the system will pick the smallest value). This guide uses 100MB and 2%, change values accordingly. You need to be rooted. Procedure overview (step-by-step below):

Database Path: /data/data/com.android.providers.settings/databases/settings.db

Insert rows in table: global

name value
sys_storage_threshold_percentage 2
sys_storage_threshold_max_bytes

104857600

 

Note: In older Android the table might be named secure. If that is the case please replace global by secure in the following instructions. Thanks to Patrick in the comments!

 

Using a sqlite3 editor:
  1. Get a rooted sqlite3 editor from the play store. I tested this procedure successfully with SQLite Debugger and aSQLiteManager. SQLite Master Pro is easier to use but not free.
  2. Open the aforementioned database.
  3. Navigate to the table named global.
  4. Insert the rows as specified. (when inserting only fill name/value, leave the remaining fields empty)
  5. reboot!
Using the command line:
  1. You will need a rooted phone with sqlite3. If you do not have the sqlite3 command installed, try this one or try the Sqlite3 installer.
  2. Connect to your phone via adb shell or use a root terminal emulator.
  3. # sqlite3 /data/data/com.android.providers.settings/databases/settings.db
    SQLite version 3.8.6 2014-08-15 11:46:33
    Enter ".help" for usage hints.
    sqlite> replace into global (name, value) values('sys_storage_threshold_percentage', '2');
    sqlite> replace into global (name, value) values('sys_storage_threshold_max_bytes', '104857600');
    sqlite> .quit
    # reboot

You should be able to install more apps now :)

 

Look further

A quick note about the table name first: I instructed you to insert lines in the "global" table. I believe the proper place for all Android is the "secure" table and "global" has the ability to override settings from "secure". I have not tested recent Android 4+ with "secure" instead of "global", that's why I kept "global" above.

Here's some technical info if you want to patch at the rom level or write an xposed mod or whatever:

I tracked the check down to getMemThreshold() in DeviceStorageMonitorService.java.

private long getMemThreshold() {
     long value = Settings.Secure.getInt(
                            mContentResolver,
                            Settings.Secure.SYS_STORAGE_THRESHOLD_PERCENTAGE,
                            DEFAULT_THRESHOLD_PERCENTAGE);
         if(localLOGV) Slog.v(TAG, "Threshold Percentage="+value);
         value *= mTotalMemory;
         long maxValue = Settings.Secure.getInt(
                 mContentResolver,
                Settings.Secure.SYS_STORAGE_THRESHOLD_MAX_BYTES,
                DEFAULT_THRESHOLD_MAX_BYTES);
    //evaluate threshold value
    return value < maxValue ? value : maxValue;
}

The default value is specified earlier in the same file:

private static final int DEFAULT_THRESHOLD_PERCENTAGE = 10;
private static final int DEFAULT_THRESHOLD_MAX_BYTES = 500*1024*1024; // 500MB

The setting key can be found in frameworks/base/core/java/android/provider/Settings.java

The installer calls it from PackageManagerService.java in checkFreeStorage()

 

Method with Tasker:

(From Daniel in the comments.)

For those having tasker it is even easier:

Task with this 2 actions:

  1. Run shell (under code) - enter the following values
    1. Command: sqlite3 /data/data/com.android.providers.settings/databases/settings.db "replace into global (name, value) values('sys_storage_threshold_percentage', '2')";
    2. Tick "use root"
    3. If you want you can save the error output and display it with a notify action
  2.  2nd action same but put this command:
    1. sqlite3 /data/data/com.android.providers.settings/databases/settings.db "replace into global (name, value) values('sys_storage_threshold_max_bytes', '104857600')";

Run the task and reboot ...

14 comments
Commentaires
avatar
Hello Alex! I have followed your instructions step by step, using the sqlite3 editor method. After accessing the database path ( /data/data/com.android.providers.settings/databases/settings.db) using aSQLiteManager...

http://i356.photobucket.com/albums/oo1/patrick0000Dumi/2015-01-23-12-36-14-593_zpsb6cffa9c.png

...it appears that my database doesn't have a table named "global", therefore I cannot insert the rows you specified.

http://i356.photobucket.com/albums/oo1/patrick0000Dumi/2015-01-23-12-20-54-953_zps5f613e45.png

My phone is gingerbread based, 2.3.3 version. Can I still solve the "Insufficient Storage available" issue?
avatar
alex
Administrateur
Hello Patrick!

I have just checked the Java code for gingerbread; You have a table named "secure" and the setting's full name is Settings.Secure.SYS_STORAGE_THRESHOLD_PERCENTAGE. It's just a guess but you can try inserting the rows in the "secure" table instead of global.


It is very unlikely to be dangerous, but I do not have any gingerbread device to test so please do a backup first!
avatar
Done it, Alex! I've inserted only the first row, the percentage one, in the secure table ('sys_storage_threshold_percentage', value '1') and it's working like a charm!

Thank you and keep up the good work! :)
avatar
alex
Administrateur
Thanks for the update! I'll add this info in my article.
avatar
Hai Alex, happy to see the solution. But I happen to see some more easy way to solve the insufficient storage issues in tablets. My BSNL penta tablet always shows this issue. And I had cleared the cache of Google Chrome, Clash of clans, Facebook etc as seen in http://firstandgeek.com/5-ways-solve-insufficient-storage-available-android/ Now i have more storage space.
avatar
Dozorengel
Really thanks for the solution, it works on CM11 with only the first row inserted in "global" table.
avatar
Hi

Thanks for this guide - highly appreciated!

For those having tasker it is even easier:
Task with this 2 actions:
Run shell (under code) - enter the following values
Command: sqlite3 /data/data/com.android.providers.settings/databases/settings.db "replace into global (name, value) values('sys_storage_threshold_percentage', '2')";
Tick "use root"
If you want you can save the error output and display it with a notify action

2nd action same but put this command: sqlite3 /data/data/com.android.providers.settings/databases/settings.db "replace into global (name, value) values('sys_storage_threshold_max_bytes', '104857600')";

Run the task and reboot ...

You may add this to the official description - I guess lots of people have tasker and so no additional app is needed

Regards
Daniel
avatar
alex
Administrateur
Hello Daniel,

Thank you for sharing. I added your method to the guide!
avatar
Thank you for sharing for a great method to get rid of this insufficient space error. Although this method requires a rooted device, So people who don't have rooted device can try this method -
http://www.geeksgyaan.com/2015/04/fix-insufficient-Space-error.html
avatar
Thanks for this guide - highly appreciated!

For those having tasker it is even easier:
Task with this 2 actions:
Run shell (under code) - enter the following values
Command: sqlite3 /data/data/com.android.providers.settings/databases/settings.db "replace into global (name, value) values('sys_storage_threshold_percentage', '2')";
Tick "use root"
If you want you can save the error output and display it with a notify action http://techonloop.com/hulu-plus-login
avatar
Encountered an error on CM13.1 using terminal method: no such table global
avatar
thx Alex it worked for me ????????????? Using a sqlite3 editor it worked keep posting more like that!!!????
avatar
Ozkan Aksayar
I was try the solve on General Mobile Discovery 1 but i have into bootloop.
avatar
Thanks a lot for the guide! It worked wonders!
Connectez-vous ou postez en tant qu'invité:
Your Name Your Email


Vérification: 2970
Go to Top