解决方案 »

  1.   

    http://blog.csdn.net/vary25/article/details/6278285
      

  2.   

    试试这个,应该好使
     // Tell the media scanner about the new file so that it is
                // immediately available to the user.
                MediaScannerConnection.scanFile(this,
                        new String[] { file.toString() }, null,
                        new MediaScannerConnection.OnScanCompletedListener() {
                    public void onScanCompleted(String path, Uri uri) {
                        Log.i("ExternalStorage", "Scanned " + path + ":");
                        Log.i("ExternalStorage", "-> uri=" + uri);
                    }
                });
    祝你成功!
      

  3.   

    Uri data = Uri.parse("file://" +"这里是图片路径");
    sendBroadcast(new  Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, data));
      

  4.   

    注意:Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,是只扫描文件的,不会扫描文件夹的,得你自己查找指定文件private void scanSdCard(){
            String file= Environment.getExternalStorageDirectory().getAbsolutePath()+"/Photo";
            folderScan(file);
        }
        
        private void fileScan(String file){
            sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file)));
        }
        
        private void folderScan(String path){
            File file = new File(path);
            
            if(file.exists() && file.isDirectory()){
                File[] array = file.listFiles();
                
                for(int i=0;i<array.length;i++){
                    File f = array[i];
                    
                    if(f.isFile()){//FILE TYPE
                        String name = f.getName();
                        
                        if(name.endsWith(".mp4") || name.endsWith(".mp3") || name.endsWith(".jpg")){
                            fileScan(f.getAbsolutePath());
                        }
                    }
                    else {//FOLDER TYPE
                        folderScan(f.getAbsolutePath());
                    }
                }
            }
        }