【问题标题】:Adding files to Assets folder. Android将文件添加到 Assets 文件夹。安卓
【发布时间】:2019-03-22 09:03:40
【问题描述】:

我正在使用 Assets 文件夹来存储文件。并添加了文件

十种方式

手动到这个文件夹。但是当我在这段代码的帮助下显示这个文件夹的文件列表时

AssetManager manager = getApplicationContext().getAssets();
        try {
            String[] files = manager.list("");
            Toast.makeText(getApplicationContext(),files[0],Toast.LENGTH_SHORT);
        } catch (IOException e) {
            e.printStackTrace();
        }

什么都没有显示。我知道这意味着这个文件夹中没有任何内容,但是为什么呢?

这是目录的结构:

【问题讨论】:

    标签: android file android-studio directory android-assets


    【解决方案1】:

    使用Toast 时的常见错误。你忘记展示了:

    Toast.makeText(getApplicationContext(),files[0],Toast.LENGTH_SHORT).show();
    

    【讨论】:

      猜你喜欢
      • 2019-11-06
      • 1970-01-01
      • 2015-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-26
      相关资源
      最近更新 更多