Android 从图库中获取图像

Android 从图库中获取图像,android,Android,我的应用程序从库中获取图像并复制到子文件夹。但是,复制的图像作为原始图像的副本从不同的位置进入画廊 如何预防?请帮帮我 这是我要保存到预定义文件夹的代码 protected String saveBitmap(Bitmap bm, String path) throws Exception { String tempFilePath="/sdcard/AuFridis/Events/Images/"+System.currentTimeMillis()+"myEventImg.jpg";

我的应用程序从库中获取图像并复制到子文件夹。但是,复制的图像作为原始图像的副本从不同的位置进入画廊

如何预防?请帮帮我

这是我要保存到预定义文件夹的代码

protected String saveBitmap(Bitmap bm, String path) throws Exception {
    String tempFilePath="/sdcard/AuFridis/Events/Images/"+System.currentTimeMillis()+"myEventImg.jpg";
    File tempFile = new File(path+"/"+System.currentTimeMillis()+"myEventImg.jpg");
   // File tempFile = new File("/sdcard/Notes");
    tempFile.createNewFile();

    if (!tempFile.exists()) {
        if (!tempFile.getParentFile().exists()) {
            tempFile.getParentFile().mkdirs();
        }
    }

    //tempFile.delete();
    //tempFile.createNewFile();

    int quality = 100;
    FileOutputStream fileOutputStream = new FileOutputStream(tempFile);

    BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
    bm.compress(CompressFormat.JPEG, quality, bos);

    bos.flush();
    bos.close();

    //bm.recycle();
    Log.i("On saveBitmap Function - retrieved file path", "---"+tempFilePath);
    return tempFilePath;

}

您是否试图从库中隐藏图像?默认情况下,Android会扫描设备的内存,并将找到的所有照片放入多媒体资料中。设备最有可能看到重复的名称和标签。只需更改图像名称。

默认情况下,android会扫描SD卡并将找到的所有图像添加到图库中。如果将图像从库复制到另一个文件夹,该文件夹将自动添加到库中。为了防止出现这种情况,请将名为
.nomedia
的空文件添加到目标文件夹中,这样复制的图像将不会显示在库中。

那么现在在库中你会看到图像两次吗?一个是原件,另一个是你的应用程序复制的?你能再解释一下吗。。请。。wats this.nomedia?android会在SD卡内容每次更改时扫描SD卡,并自动将找到的每一张图像和视频添加到图库中。应用程序可以选择阻止其媒体被索引/添加-如果android在文件夹中看到一个名为
.nomedia
的文件,那么它将跳过该文件夹,并且该文件夹中的图像和视频将不会被扫描/索引/添加到gallery中。