[Android]向sdcard中写入文件
一,添加函数try {
File saveFile=new File("/sdcard/zhzhg.txt");
FileOutputStream outStream = new FileOutputStream(saveFile);
try {
outStream.write("文件的读写".getBytes());
}
catch (IOException ex)
{
Logger.getLogger(DeviceListActivity.class.getName()).log(Level.SEVERE, null, ex);
}
try
{
outStream.close();
}
catch (IOException ex)
{
Logger.getLogger(DeviceListActivity.class.getName()).log(Level.SEVERE, null, ex);
}
} www.zzzyk.com
catch (FileNotFoundException ex)
{
Logger.getLogger(DeviceListActivity.class.getName()).log(Level.SEVERE, null, ex);
}
二,设置向存储卡读写权限
在AndroidMainfest.xml文件中添加:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
补充:移动开发 , Android ,