Storing files on android phones is an essential function for each of our mobile users. For developers, skilled operations on various files can be of great help to our development, the following androidkaifa.com describes how to obtain file paths provided by an android API file. Which file is the actual file path corresponding to them!
Package com. herongyang;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. widget. TextView;
Import android. widget. ScrollView;
Import android. OS. Environment;
Public class AboutAndroid extends Activity {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
String msg = "";
Msg + = "System properties \ n ";
Msg + = "------------- \ n ";
Java. util. Properties props = System. getProperties ();
Java. util. Enumeration e = props. propertyNames ();
While (e. hasMoreElements ()){
String k = (String) e. nextElement ();
String v = props. getProperty (k );
Msg + = k + ":" + v + "\ n ";
}
Msg + = "\ n ";
Msg + = "Envirionment variables \ n ";
Msg + = "------------- \ n ";
Java. util. Map envs = System. getenv ();
Java. util. Set keys = envs. keySet ();
Java. util. Iterator I = keys. iterator ();
While (I. hasNext ()){
String k = (String) I. next ();
String v = (String) envs. get (k );
Msg + = k + ":" + v + "\ n ";
}
Msg + = "\ n ";
Msg + = "Environment folders \ n ";
Msg + = "------------- \ n ";
Msg + = "Data folder:" + Environment. getDataDirectory (). getPath () + "\ n ";
Msg + = "Download cache folder:" + Environment. getDownloadCacheDirectory (). getPath () + "\ n ";
Msg + = "External Storage folder:" + Environment. getExternalStorageDirectory (). getPath () + "\ n ";
Msg + = "Root folder:" + Environment. getRootDirectory (). getPath () + "\ n ";
Msg + = "\ n ";
Msg + = "Application context info \ n ";
Msg + = "------------- \ n ";
Msg + = "Cache folder:" + getCacheDir (). getPath () + "\ n ";
Msg + = "External cache folder:" + getExternalCacheDir (). getPath () + "\ n ";
Msg + = "File folder:" + getFilesDir (). getPath () + "\ n ";
Msg + = "OBB folder:" + getObbDir (). getPath () + "\ n ";
Msg + = "Package name:" + getPackageName () + "\ n ";
Msg + = "Package code path:" + getPackageCodePath () + "\ n ";
Msg + = "Package resource path:" + getPackageResourcePath () + "\ n ";
TextView TV = new TextView (this );
TV. setText (msg );
ScrollView sv = new ScrollView (this );
Sv. addView (TV );
SetContentView (sv );
}
}
Run the application and obtain the following information ::
Data folder:/data
Download cache folder:/cache
External storage folder:/mnt/sdcard
Root folder:/system www.2cto.com
Cache folder:/data/com. herongyang/cache
External cache folder:/mnt/sdcard/Android/data/com. herongyang/cache
File folder:/data/com. herongyang/files
OBB folder:/mnt/sdcard/Android/obb/com. herongyang
Package name: com. herongyang
Package code path:/data/app/com.herongyang-1.apk
Package resource path:/data/app/com.herongyang-1.apk