做android 开发的时候经常涉及到权限的问题,而我们像sdcard中写入文件的时候就要判断是否有权限,以及sdcard是否存在,判断sdcard是否存在的权限:[color=red]<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">
</uses-permission>[/color]
写入文件到sdcard中:
File f = new File(path);
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED))//sd存在并可写
{
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(f));
osw.write(你要输入的值);
}
</uses-permission>[/color]
写入文件到sdcard中:
File f = new File(path);
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED))//sd存在并可写
{
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(f));
osw.write(你要输入的值);
}