Home > Mobile >  An issue of writing after the U disk data
An issue of writing after the U disk data

Time:10-12

System is compiled myself, have modify write u disk permissions
The question now is, after I write u disk files, drawn directly, to the computer, have in the file, but no data
If I were in storage there uninstall u disk, or put the android shutdown and then pull out u disk, then there is data
But it is hard to require customers to do so, is there any way to write u disk not cache the data?
My code is as follows,
 public static void writeSDFile_UTF8 (Context CTX, String fileName, String write_str) throws IOException {

The File File=new File (fileName);
if (! File. The exists ()) file. CreateNewFile ();//set up files

FileOutputStream fos=new FileOutputStream (file);
If (the file. The length () & lt; 1) {

Final byte []=new bom byte [] {0 xef (byte), (byte) 0 XBB, XBF (byte) 0};

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);
}

CodePudding user response:

To modify the android source code solution can also accept

CodePudding user response:

Resolved
Combined with fos. GetFD (). The sync (); Can be

CodePudding user response:

Hello, could you tell me what the specific reasons for this phenomenon?
  • Related