Android获取程序路径 (/data/data/appname)

Android获取文件夹路径 /data/data/

http://www.2cto.com/kf/201301/186614.html


 

String printTxtPath = getApplicationContext().getPackageResourcePath() + "/files/" + fileName;
=> /data/app/com.example.fileoperation-2.apk/files/printMenu.txt

String printTxtPath = getApplicationContext().getFilesDir();
String printTxtPath = getApplicationContext().getFilesDir().getAbsolutePath();
=> /data/data/com.example.fileoperation/files


//获取当前程序路径

getApplicationContext().getFilesDir().getAbsolutePath();

//获取该程序的安装包路径

String path=getApplicationContext().getPackageResourcePath();

//获取程序默认数据库路径

getApplicationContext().getDatabasePath(s).getAbsolutePath();

posted @ 2014-04-25 15:46  petercao  阅读(64142)  评论(0编辑  收藏  举报