【问题标题】:FileNotFoundException AndroidFileNotFoundException Android
【发布时间】:2011-11-02 05:30:42
【问题描述】:

我有一个非常愚蠢的异常出现并扰乱了我的想法。

我在 assets 文件夹中有一个 xml 文件,它说明在哪里可以找到我的应用程序的内容更新。

所以我使用 xmlpullparser 来解析我的资产 xml 文件,然后从那里获取链接,然后我使用代码 sn-p 作为:

PullLoadData pld = new PullLoadData("versioncheck.xml",SplashScreen.this);
                pld.checkUpdate();
                int fileSize = 0;
                InputStream is;
                AssetManager assetMgr = getAssets();
                PullLoadData pldContent;
                File file = new File(getString(R.string.database_path)+ "ext");
                progressBar.setMax(100);
                for (int i = 0; i < pld.result.size(); i++) {
                    int results = 0;
                    for (int j = 0; j < issue.length; j++) {
                        if (pld.result.get(i).get("issue").equals(issue[j])) {
                            results = 1;
                        }
                    }
                    if (results == 0) {

                        Log.i(TAG, "ZIP Link "+ pld.result.get(i).get("link"));

                        is = assetMgr.open(pld.result.get(i).get("link"));}

// 我得到了 zip 文件的正确 url,并使用浏览器中的这个链接我可以下载 zip 文件......但是在调试时我得到 FileNotFoundException。

任何想法我哪里错了?

【问题讨论】:

  • 我想我们需要使用 URL url = new URL("your link");然后使用 URLConnection urlconn = url.openConnection();

标签: android filenotfoundexception android-assets


【解决方案1】:

你可以试试这个

Uri 路径 = Uri.fromFile(new File("assets/yourxmlfile.xml"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多