`

2013.12.23 ——— android assents文件路径

 
阅读更多
2013.12.23 ——— android assents文件路径

我在assents下面放了一个a.apk,想得到绝对路径

1、
for(String tStr : getAssets().list("")){
                System.out.println(tStr);
}


执行结果:

12-23 13:12:14.733: I/System.out(13814):a.apk
12-23 13:12:14.733: I/System.out(13814): images
12-23 13:12:14.733: I/System.out(13814): sounds
12-23 13:12:14.733: I/System.out(13814): webkit


没有得到绝对路径,只是列出了名字,至于后面三个是什么 应该是默认就有的


2、
File tFile = new File(getDir("assents", 0) + File.separator + "a.apk");
            if(tFile.exists()){
                System.out.println(tFile.getAbsolutePath());
                System.out.println(tFile.getCanonicalPath());
                System.out.println(tFile.getPath());
            }


没有打印

3、
引用
apk安装以后放在/data/app/**.apk,以apk形式存在,asset/res和apk在一起,并不会解压到/data/data/YourApp目录下去,所以你无法直接获取到assets的绝对路径,因为他根本木有


所以 只好曲线救国了,把assents的文件复制到sdcard上吧


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics