Android under the application of the path and javase different, the application of the data to save their own folder inside> > Getfiledir (); Get your own folder/data/data/package name (application name)/Files> Getcachedir (); /data/data/Package Name (name of application)/The cache Google gives us a directory of two applications, the files directory, which holds important application data. The phone does not automatically clean up files directories, such as configuration information, the removal of the software is cleared here. The cache directory is a temporary, unimportant data. This directory is specific, when the phone memory space is not enough to automatically clean up the cache directory files, the software to clear the cache is cleared here. # #手机存储空间的划分*Phone internal storage (files and cache, relatively small general 2g4g, Xiaomi Phone memory 16G is included in the external storage SD card,) environment.getdatadirectory ()>file directory cache directory>limited capacity, smaller, more expensive, faster storage access> Created files in the phone's internal storage space, * * Default * *the permissions are all private.>only your own application can access it,>Other applications cannot be accessed.> Why do I need to declare permissions? *Phone External Storage environment.getexternalstoragedirectory ()>SD card>large capacity, can be replaced, inexpensive, 32G less than 200 dollars> Read and Write claims permissions
Packagecom.itheima.storagesize;ImportJava.io.File;Importandroid.app.Activity;ImportAndroid.os.Bundle;Importandroid.os.Environment;ImportAndroid.text.format.Formatter;ImportAndroid.widget.TextView; Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); File datafile= Environment.getdatadirectory ();//Data internal storage spaceFile sdfile = Environment.getexternalstoragedirectory ();//External storage space LongDataSize =Datafile.gettotalspace (); LongSdsize = Sdfile.gettotalspace ();//Unit is byteTextView TV =(TextView) Findviewbyid (r.id.tv); Tv.settext ("Internal storage:" + formatter.formatfilesize ( This, datasize) + "\ n" + "external SD card:" + formatter.formatfilesize ( This, sdsize)); //Samsung Millet Meizu//Some manufacturers of SD card directory:/mnt/sdcard//Some manufacturers of SD card directory:/MNT/STORAGE01//Some manufacturers of SD card directory:/MNT/STOARGE02//Some manufacturers of SD card directory:/MNT/MOUNT/STOARGE01 }}
The partition of Android 62 mobile phone storage Directory