1

After downloading images it saves them to this location

 String extStorageDirectory;
protected void onCreate(Bundle icicle) {
extStorageDirectory = Environment.getExternalStorageDirectory().toString(); //set it to the SD card directory
}

 public void savetoSD(Integer Index) //Index is what pic number it is 1 through 9
    {
        OutputStream outStream = null;
        String filename = "Hentai" + System.currentTimeMillis() + ".JPEG";
        String filepath = extStorageDirectory + "/media/pictures/MyAppsDownloadFolder/" + filename;
        File file = new File(filepath);
           try {
            outStream = new FileOutputStream(file);
            //get a download here for the real bitmap
            DownloadFromUrl(myMainPicURL[Index],filename);
            Bitmap saveME = null;
                    saveME = BitmapFactory.decodeFile(PATH+filename);
                    saveME.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
                outStream.flush();
                outStream.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            //need to refresh the damned MediaScanner
            try {
                MediaStore.Images.Media.insertImage(getContentResolver(), filepath, filename, "myDownloadedPics");
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            message_user("Saved as " + filepath);
    }

I believe the mediastore doesnt work or i dont know how to use it please help

I want the downloaded images to appear in the gallery or atleast have the folder MyAppsDownloadFolder to show in the gallery which it doesnt!

4

1 回答 1

2

媒体扫描仪不会自动扫描 SD 卡,除非打开设备或从主机 PC 上卸载 SD 卡。

如果您希望媒体扫描仪专门进行按需扫描,请使用MediaScannerConnection.

于 2010-11-26T20:57:08.110 回答