public void putSdcard(String s, String tep) {
try {
FileOutputStream outStream = new FileOutputStream("/sdcard/" + tep
+data.getOrderCode()+ ".txt");
File file = new File("/sdcard/" + tep
+data.getOrderCode()+ ".txt");
outStream.write(s.getBytes());
outStream.flush();
outStream.close();
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
this.sendBroadcast(intent);
showToast(this, "保存本地成功,连接电脑后查看");
} catch (Exception e) {
e.printStackTrace();
showToast(this, "保存失败");
}
}
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
this.sendBroadcast(intent);
只需要增加三行代码 在文件保存完毕后发送广播刷新一下 就能在电脑中查看了