Understanding the storages in an Android device, you can easily check or transfer files in both directions: your app and the device. For example, if your app have a licence file, and you want to check the permission, you can store licence file in Android device for further updating and changing.

Storages in an Android Device

To work with your device’s file system, do the following:

  1. Open the device file browser by clicking View > Tool Windows > Device File Explorer.
  2. Select a device from the drop-down list.

There two useful storages you can store your data:

  • one is the internal storage, which is located at: data/data/app_name/
  • another one is the external user storage, which is located at: sdcard/

Examples for Creating files

Here is a sample code that creates a file in the internal storage:

1
2
3
4
5
6
7
8
9
10
11
12
13
 public void createFile() {
try {
File checkFile = new file(context.getApplicationInfo().dataDir + "/new_directory_name/");
if(!checkFile.exists()) {
checkFile.mkdir();
}
FileWriter file = new FileWriter(checkFile.getAbsolutePath() + "/filename");
file.write("what you want to write in internal storage");
file.flush();
file.close();
} catch(IOException e) {
e.printStackTrace();
}