
Android Studio中编辑区上面有一块显示当前打开文件的路径的区域,如下图
或者你想在左边的结构目录中快速定位到这个文件,你可以点击下图中红框标记的那个按钮
这样就可以在这个结构目录中看到这个文件了;
再或者你想直接打开这个文件所在的文件夹,那就在上面说得结构目录中的这个文件上右键,如果是Windows下的话会有一个Show in exploer,Mac的话是Reveal in Finder,点击它就可以打开这个文件所在的文件夹查看了。
android无法获取res资源文件夹路径,只能通过系统提供的封装函数访问。
资源文件夹有:
/res/drawable
,通过getresources()访问
/res/values
,通过getresources()访问
/res/layout,通过getresources()访问
/res/xml,通过getresources()访问
/res/raw,通过getresources()访问
/assets,通过getassets()访问
package comhangchengutil;
import javaioFile;
import javaioFileOutputStream;
import javaioIOException;
import javaioInputStream;
import javautilArrayList;
import javautilHashMap;
import javautilList;
import androidappActivity;
import androidcontentContext;
import androidcontentresAssetManager;
public class GetfilesFromAssets {
private Activity activity;
private String[] files;
public GetfilesFromAssets(Context context) {
thisactivity = (Activity) context;
}
// public void deepFile(Context ctxDealFile, String path) {
// try {
// String str[] = ctxDealFilegetAssets()list(path);
// if (strlength > 0) {// 如果是目录
// File file = new File("/data/" + path);
// filemkdirs();
// for (String string : str) {
// path = path + "/" + string;
// Systemoutprintln("zhoulc:\t" + path);
// // textViewsetText(textViewgetText()+"\t"+path+"\t");
// deepFile(ctxDealFile, path);
// path = pathsubstring(0, pathlastIndexOf('/'));
// }
// } else {// 如果是文件
// InputStream is = ctxDealFilegetAssets()open(path);
// FileOutputStream fos = new FileOutputStream(new File("/data/"
// + path));
// byte[] buffer = new byte[1024];
// int count = 0;
// while (true) {
// count++;
// int len = isread(buffer);
// if (len == -1) {
// break;
// }
// foswrite(buffer, 0, len);
// }
// isclose();
// fosclose();
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// eprintStackTrace();
// }
// }
public String[] getfileFromAssets(String path) {
AssetManager assetManager = activitygetAssets();
// String[] files;
try {
files = assetManagerlist(path);
} catch (IOException e) {
// TODO Auto-generated catch block
eprintStackTrace();
}
return files;
}
public List listHtmlOfAssets() {
List list = new ArrayList();
files = getfileFromAssets("html");
for (int i = 0; i < fileslength; i++) {
HashMap map = new HashMap();
mapput("htmlname", files[i]);
listadd(map);
}
return list;
}
}
以上就是关于Android Studio快速定位当前打开的文件在哪个目录下全部的内容,包括:Android Studio快速定位当前打开的文件在哪个目录下、android下怎么获取res资源文件夹的路径、Android如何获取asset目录下所有文件的路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)