相关疑难解决方法(0)

从资产中读取文件

public class Utils {
    public static List<Message> getMessages() {
        //File file = new File("file:///android_asset/helloworld.txt");
        AssetManager assetManager = getAssets();
        InputStream ims = assetManager.open("helloworld.txt");    
     }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码尝试从资产中读取文件.我尝试了两种方法来做到这一点.首先,当File我收到使用FileNotFoundException时,使用AssetManager getAssets()方法时无法识别.这里有解决方案吗?

android

167
推荐指数
8
解决办法
31万
查看次数

标签 统计

android ×1