Android在SDcard建文件夹以及Android路径大全

转自文章 http://www.linuxidc.com/Linux/2012-11/74781.htm

                 http://www.2cto.com/kf/201306/223572.html


获取Android设备的外存路径的接口为:

  1. Environment.getExternalStorageDirectory().getAbsolutePath()

所以,给自己的程序建个目录可如下所写:

  1. String appHome = Environment.getExternalStorageDirectory().getAbsolutePath()+"/myApp";
  2. createDir(appHome)

但是,如果要建多层目录的文件夹的话,可不能一蹴而就。像下面这样写代码的话,执行代码后,在Android设备的外存里是不会创建文件夹“myApp/sub”的:

  1. String appHome = Environment.getExternalStorageDirectory().getAbsolutePath()+"/myApp";
  2. createDir(appHome)

如果要建多层目录的文件夹,只能是一步一步的建,如下所示:

  1. String appHome = Environment.getExternalStorageDirectory().getAbsolutePath()+"/myApp";
  2. String subPath = appHome+"/sub";
  3. createDir(appHome);
  4. createDir(subPath);




Android不同api调用显示的路径:

 

 

[java]
Environment.getExternalStorageState:mounted 
Environment.getDownloadCacheDirectory().getPath():/cache 
Environment.getDataDirectory().getPath():/data 
Environment.getExternalStorageDirectory().getPath():/mnt/sdcard 
Environment.getExternalStoragePublicDirectory().getPath():/mnt/sdcard/Pictures 
Environment.getRootDirectory().getPath():/system 
 
Environment.getDownloadCacheDirectory().getAbsolutePath():/cache 
Environment.getDataDirectory().getAbsolutePath():/data 
Environment.getExternalStorageDirectory().getAbsolutePath():/mnt/sdcard 
Environment.getExternalStoragePublicDirectory().getAbsolutePath():/mnt/sdcard/Pictures 
Environment.getRootDirectory().getAbsolutePath():/system 

Environment.getExternalStorageState:mounted
Environment.getDownloadCacheDirectory().getPath():/cache
Environment.getDataDirectory().getPath():/data
Environment.getExternalStorageDirectory().getPath():/mnt/sdcard
Environment.getExternalStoragePublicDirectory().getPath():/mnt/sdcard/Pictures
Environment.getRootDirectory().getPath():/system

Environment.getDownloadCacheDirectory().getAbsolutePath():/cache
Environment.getDataDirectory().getAbsolutePath():/data
Environment.getExternalStorageDirectory().getAbsolutePath():/mnt/sdcard
Environment.getExternalStoragePublicDirectory().getAbsolutePath():/mnt/sdcard/Pictures
Environment.getRootDirectory().getAbsolutePath():/system


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值