Explanation of various storage paths for android

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.