如何在android kitkat中刷新图库?
如何在android kitkat中刷新图库如何在android kitkat中刷新图库?,android,Android,如何在android kitkat中刷新图库 sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); 我尝试了上面的方法,但在安卓4.4中并没有让人耳目一新。以编程方式添加/删除图像时如何刷新库?尝试以下操作: if (Build.VERSION.SDK_INT >= Build.VERSION_COD
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
我尝试了上面的方法,但在安卓4.4中并没有让人耳目一新。以编程方式添加/删除图像时如何刷新库?尝试以下操作:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File("folderPATH", "fileName"); //OR File f = new File(YourCurrentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
appContext.sendBroadcast(mediaScanIntent);
} else {
appContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/" + "FOLDER_TO_REFRESH")));
}
就是这样…添加一些代码来查找错误