Bug from delete image file using android

B.Nadesh kumar

I have created a Customized Gallery app using Universal image loader methods

Now, am picking out an image from the Gallery and moving it to my app folder. And am deleting the particular selected image from the Gallery.The problem now is that even after the deletion of the image, the imge is still visible in the Gallery and blinks showing 0.0 KB memory in same file name.How to clear the Bug

Please help me how to solve this bug.

Note:

I have moved the image from the source path to the destination. And my destination received the particular image.

And then when i finally delete the image from the source part, the image is still visible same filename for example :IMG_20151106_193.jpg memory size 0.0kB

Code Line :

  @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {
        if (resultCode == RESULT_OK) {

            ArrayList<String> result = data.getStringArrayListExtra(Gallery_picker.KEY_ARRAYLIST_SELECTED_PHOTOS);
            mSelectedPhotos.clear();
            if (result == null) {
                return;
            }

            Iterator<String> iterator = result.iterator();
            while (iterator.hasNext())
            {
                String path = (String) iterator.next();
                if (!mSelectedPhotos.contains(path))
                {
                    mSelectedPhotos.add(path);
                }

            }

            String[] mStringArray = new String[mSelectedPhotos.size()];
            mStringArray = mSelectedPhotos.toArray(mStringArray);
            for(int i = 0; i <mStringArray.length ; i++)
            {

                String path=""+ (String)mStringArray[i];//it contain your path of image..im using a temp string..
                String filename=path.substring(path.lastIndexOf("/")+1);

                /*** Move file in SD Card ***/
                try {
                    File extStore = Environment.getExternalStorageDirectory();
                    fis = new File(path);
                    File fos = new File(extStore +"/Myfoldername/"+Subfoldername+"/"+customsimagename+".jpg");
                    copyFile(fis, fos); // Copy
                    fis.delete();

                } catch (Exception e)
                {

                    // TODO Auto-generated catch block
                    e.printStackTrace();
       //     Toast.makeText(this, "Failed! = " + e.getMessage(),Toast.LENGTH_LONG).show();
                }

            }
        }
    } catch (Exception e) {

    }


}        
starkshang

After change imgae path,you should notify the gallery to update,so you should send a broadcast to make it. Before 4.4,you can call this:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+Environment.getExternalStorageDirectory())));  

After 4.4,try this:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file)));//the file is new image's path

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

image from a file in android

Delete the uploded image file using ajax code

Delete image file using ajax call

Deleting a file from storage does not delete an image

How to delete image file from Android Internal when path is stored in SQLite DB

deleting an image file from the file system and then adding a new image file with the same name returns an old image when added using Uri in android

Parse Server - How to delete image file from the server using cloud code

Delete image from folder using data list

Delete image from database using ajax and php

Delete Row From GridView using cancel Image

Need to delete uploaded image file from image folder

How to delete an image file from GridFS by file metadata?

how to delete a file from android studio code

How to delete a file from the internal memory in Android?

Delete images from pptx file using python

Delete File from remote server using SftpRemoteFileTemplate

Using IDisposable to Delete a File from Disk

Delete several lines from a file using grep

Using VBScript to delete a column from CSV file

Android text around image bug

How To Delete Image File in Android sdk Version Lower Than 30

How to delete a image file?

Django - File or Image Delete

Cannot delete a saved image file after I am done using it

How to delete image file from specific folder path?

Delete image file from directory in PHP on remote server and localhost

android load image from url not same load image from file

Sending an image file from an Android phone to a PC through Python using sockets

Android take image path from text file