0
private void readFileFromSDCard() {
        File directory = Environment.getExternalStorageDirectory();

        File file = new File(directory+"/HomeActivityLogs");
        //file.getParentFile().mkdirs();

        if (!file.exists()) {

            FileWriter gpxwriter;
            try {
                System.out.println(" IN TRY Error");
                file.createNewFile();
                gpxwriter = new FileWriter(file);

                System.out.println(" file writer Error");
            BufferedWriter out = new BufferedWriter(gpxwriter);
            out.write("http://192.168.1.126/msfaws2_4/Service.asmx");
            System.out.println(" in url Error");
        ///    out.write("http://192.168.1.250/msfaws2_4/Service.asmx");
            out.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                loginLog.appendLog("Exception in readFileFromSDCard() " + e.getMessage(),"MainActivity");
            }
        }

        BufferedReader reader = null;
        try {
            System.out.println("Error");
            reader = new BufferedReader(new FileReader(file));
            StringBuilder builder = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
            Constant.URL = builder.toString();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                    loginLog.appendLog("Exception in readFileFromSDCard() " + e.getMessage(),"MainActivity");
                }
            }
        }
}

请帮我解决这个问题。当数据被临时存储然后从活动中检索时,它会给出一个错误 filenotfound 及其从 Web 服务动态创建的文件名。

4

1 回答 1

0

试试这个,在你里面添加这个权限manifest.xml

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
于 2013-03-23T13:25:22.047 回答