获取android的各种路径

来源:互联网 发布:郭美美事件 知乎 编辑:程序博客网 时间:2024/05/22 14:23

有时候我们需要访问android的很多路径,下面我们就来总结一下android的一些目录的获取方式:


//  获取当前程序路径    getApplicationContext().getFilesDir().getAbsolutePath();//  获取该程序的安装包路径    String path=getApplicationContext().getPackageResourcePath();//  获取程序默认数据库路径    getApplicationContext().getDatabasePath("s").getAbsolutePath();
<span style="color: rgb(51, 51, 51); font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 24px; background-color: rgb(245, 245, 245); ">         //获取"/sdcard/"  sdcard的文件夹目录 </span>
<span style="background-color: rgb(245, 245, 245); "><span style="white-space: pre; "></span>Environment.getExternalStorageDirectory()</span>
<span style="background-color: rgb(245, 245, 245); "><span style="color: rgb(51, 51, 51); font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 24px; background-color: rgb(245, 245, 245); "><span style="white-space:pre"></span>//使用SDCard目录前,需要判断是否有sdcard:Environment.getExternalStorageState() ,<span style="color: rgb(51, 51, 51); font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 24px; background-color: rgb(245, 245, 245); ">操作此目录时需要在主配置文件中注册操作权限。</span></span></span>


0 0
原创粉丝点击