获得从资产目录中的文件夹名称 [英] Get folders name from Assets directory

查看:117
本文介绍了获得从资产目录中的文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的文件夹名称中的资产。我可以通过使用方法assetManager.list获得带有AssetManager的文件的名称()。但问题是,它仅返回文件的名称,而不是文件夹的名字。所以我想用listFiles()方法,但我不能访问到资产目录;我已经尝试以下方法:

I'm trying to get the names of my folders in "assets". I can get the names of the files with an AssetManager by using the method assetManager.list(). But the problem is that it return only files' name and not folders' names. So I'm trying to use the listFiles() method but i can't access to the Assets directory; I've try the following :

File dir = new File ("file:///android_asset/");
File[] files= dir.listFiles();

但它不工作:( ...有没有一种方法可以包含在资产目录中的文件夹的名字?

But it doesn't work :( ... Is there a way to get the folders' names contained in the Assets directory ?

推荐答案

该URL的file:/// android_asset /并不指向特定的目录,它只是使用的WebView来解决资产。资产是只读和在编译时定义的,所以它的假定他们的目录结构是已知的编程。这是不方便的,但是这是它的设计方式

The URL "file:///android_asset/" doesn't point to a particular directory, it is only used by WebView to address assets. Assets are read-only and defined at compile time, so it's assumed their directory structure is known to the programmer. It's inconvenient, but that's the way it's designed

这篇关于获得从资产目录中的文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆