您的问题是存在 SDCard 内容的完全相同的副本,但看不到它们- PC 正在显示从 MTP 界面返回的内容。
存根代码来执行使文件出现所需的操作:
进口:
import android.media.MediaScannerConnection;
import android.os.Environment;
import android.util.Log;
import java.io.File;
存根代码:
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");
}