1
我正在尝试从网站URL读取,然后写入设备内部存储器。以下是我的代码,系统输出可以打印出来,但内部存储没有文件。 假设abc.xml将出现在“/data/data/my-package/abc.xml”,但没有任何内容... 请帮助我解决这个问题。未写入内部存储器
try {
URL sourceUrl = new URL("mysite.php");
BufferedReader in = new BufferedReader(
new InputStreamReader(sourceUrl.openStream()));
String inputLine;
OutputStream out = openFileOutput("abc.xml", Context.MODE_PRIVATE);
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
out.write(inputLine.getBytes());
}
in.close();
out.close();
}
catch (IOException e) {
Log.d(LOG_TAG, e + "");
}
而您的调试日志中没有任何内容? – sarnold 2012-01-16 03:43:12
您是否在清单文件中添加了此权限: uses-permission> –
MKJParekh
2012-01-16 04:18:28