系统是我自己编译的,有修改写u盘权限
现在的问题就是,我写u盘文件后,直接拔出来,到电脑上,文件有在,但是没数据
如果我在存储那边卸载u盘,或者把安卓关机再拔出u盘,那么就有数据
但是很难要求客户这么做,有没有办法把数据写入u盘而不是缓存?
我的代码如下public static void writeSDFile_UTF8(Context ctx,String fileName, String write_str) throws IOException{        File file = new File(fileName);
        if (!file.exists())     file.createNewFile();//建立文件        FileOutputStream fos = new FileOutputStream(file);
        if (file.length() < 1) {            final byte[] bom = new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF };            fos.write(bom);        }
        OutputStreamWriter  osw = new OutputStreamWriter(fos, "UTF-8");
        osw.write(write_str);
        osw.flush();
        osw.close();
        fos.flush();
        fos.close();
        MediaScannerConnection.scanFile(ctx, new String[] { file.getAbsolutePath() }, null, null);
    }