手机连接PC端后在文件管理器内新建文件,PC端无法同步更新
搞了那么多其实就一行管用
private void fileScan(){
Uri data = Uri.parse("file://" + Environment.getExternalStorageDirectory().getAbsolutePath());
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data));
}
完了别忘了在清单文件里面加权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
然后在需要刷新的地方直接用:
fileScan();
此致感谢:
http://blog.csdn.net/yudajun/article/details/7957001
http://blog.csdn.net/joyce_qin_1986/article/details/8778009
http://blog.csdn.net/u010284513/article/details/51614914#comments