SD card data sometimes does not appear on a PC when connected in USB mass storage mode (via phone)

Possible duplicate:
SDCard content exists but not visible

Phone running the Linux kernel (2.6.31) with an inserted SD card.

[QUESTION] When data is being written to the SD card (write syscall), the recording returns successfully. However, when the card (via telephone) is available as a mass storage device on a PC, data is not displayed.

Only after physically removing the card and reinserting it into it and then accessing it on the PC, the data that has been recorded will be displayed as a mass storage device. I tried fsync () after writing the data. However, he will not show.

Is the kernel supporting the cache before writing data to the SD card? If so, how can I make sure it is reset to the SD card?

0
source share
1 answer

Your problem is an exact copy of the contents of the SDCard, but they are not visible - the PC displays the contents returned from the MTP interface.

The stub code to do what you need to create the file:

Import

import android.media.MediaScannerConnection; import android.os.Environment; import android.util.Log; import java.io.File; 

stub code:

 File f = new File(Environment.getExternalStorageDirectory().getPath() + "/hello_nurse.txt"); if (! f.exists()) { try { f.createNewFile(); String[] files = new String[1]; files[0] = Environment.getExternalStorageDirectory().getPath() + "/hello_nurse.txt"; String[] mimes = new String[1]; mimes[0] = "text/plain"; MediaScannerConnection.scanFile(getApplicationContext(), files, mimes, null); } catch (Exception ex) { Log.e("SD Create", "Failed to create file", ex); return; } } else { Log.e("SD Create", "File is already present"); } 
0
source

All Articles