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

时间:2024-11-21 22:35:43

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();