重新启动后找到重复的图像条目

时间:2014-09-02 23:58:53

标签: android android-gallery

我的应用程序通过Android相机拍摄图像。拍照后,我可以在图库应用中看到该文件(MediaScanner已使用)。该图像的文件路径为/storage/emulated/legacy/[Name of app]/image1.jpg。但是,重新启动设备后,我看到位于/storage/emulated/0.[name of app]/image1.jpg的重复照片。我意识到它们代表相同的图像,因为当我删除其中一个并重启设备时,两个图像都消失了。这里的问题是什么?

        File dir = new File(imageFileName);
        if (!dir.exists())
            dir.mkdirs();
        File image = null;
        try {
            image = File.createTempFile(imageFileName, JPEG_FILE_SUFFIX, dir);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        String mCurrentPhotoPath = image.getAbsolutePath();

        File f = image;
        if (f != null) {
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
            startActivityForResult(intent,
               Constants.REQUEST_CODE_TAKE_PICTURE);
        }

        // notify Media that a new file has been saved to the file system
        MediaScannerConnection.scanFile(mContext,
        new String[] { mCurrentPhotoPath }, null,
        new MediaScannerConnection.OnScanCompletedListener() {
            public void onScanCompleted(String path, Uri uri) {
            }
        });

0 个答案:

没有答案