How To Clear Android Internal Storage

Posted on  by admin

9 Parts: How to clear Android's internal storage Backup old gallery files to an external drive or to your computer USB Driver for most Android devices Clear applications' cache and data Uninstall unused applications. Clear Storage Space on Android Phone For the proper functioning of your device, it is necessary that you get into the habit of clearing storage space on your Android Phone or Table. This can be done by periodically removing unwanted Photos, Videos, Documents and other files from your Android Phone.

1 What Is Android Internal Storage

Android allows your android application save or cache private data or files on the device memory, which is called internal storage.

Data saved or cached in internal storage are private and can be accessed only within your application, other applications cannot access them.

Furthermore, data of your application that is saved in internal storage will be also deleted if user remove your application.

2 APIs

The absolute path of internal storage folder is: /data/data/<YOUR_APP_PACKAGE_NAME>/files/. Call getFilesDir() method to obtain this path. getFilesDir() will return a object. Then you can simply use java IO APIs to read or write files under internal storage folder.

2.1 Write

We will create a simple demo application to write a file to internal storage.

Main UI controls here:

  • A Button, click to write file;
  • Another Button, click to read saved file;
  • A TextView to display the absolute file path of internal storage;

The file to be saved named hello.txt, and we'll write a string 'Hello World!' to it.

2.2 Read

How To Clear Internal Storage On Android Tablet

Reading file from internal storage is also simple, just like the common Java IO operations.

We'll add a read button in above demo application. After clicking read button, a popup Toast will display the content read from internal storage file.

2.3 Cache

How To Clear Up Internal Storage On Android

Instead of getFilesDir(), getCacheDir() will return an internal storage folder path for caching data. The absolute path returned by getCacheDir() is: /data/data/<YOUR_APP_PACKAGE_NAME>/cache/. This folder is used to cache some temporary files in your application.

How To Clear Android Internal Storage

How To Wipe Internal Storage Android From Pc

There are important differences between files folder and cache folder in internal storage.

  • The data saved under cache folder will be deleted automatically by Android system if the spare space of internal storage is not enough or full;
  • The data saved under files folder will NOT be deleted unless device user clear it explicitly.

Android provided UI interface to clear cache or data of an installed application. In your Android device or emulator, navigate to Settings > Apps > YOUR_APP > storage you can see two clear buttons.

How To Clear Android Internal Storage
  • Clear Cache: will delete all data under /data/data/<YOUR_APP_PACKAGE_NAME>/cache/;
  • Clear Data: will delete all custom data under your application folder, including BOTH/data/data/<YOUR_APP_PACKAGE_NAME>/cache/AND/data/data/<YOUR_APP_PACKAGE_NAME>/files/;

How To Clear Android Internal Storage


It is a best practice to save the important data of your application into the path that is returned by getFilesDir().