Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:59:03+00:00 2026-06-01T11:59:03+00:00

I am trying to delete the items/files in a grid view. The files are

  • 0

I am trying to delete the items/files in a grid view. The files are located in the /data/my-image-folder/. The files gets deleted at once but the UI doesn’t gets updated instantly.
Here is my code for that:

   imageFilePath = /data/<my-image-folder>/"file.jpg";
   File file = new File(imageFilePath);
    if (file.exists()) {
    boolean deleted = file.delete();
    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse(imageFilePath+ Environment.getExternalStorageDirectory())));

getview code :

View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            View gridView;

            if (convertView == null) {

                gridView = new View(context);

                // get layout from gridlayout.xml
                gridView = inflater.inflate(R.layout.gridlayout, null);

                // set value into textview
                TextView textView = (TextView) gridView
                        .findViewById(R.id.grid_item_label);
                textView.setText(fileList[position]);
                System.out.println("value of fileList[position]" + fileList[0]);
                // set image
                ImageView imageThumbnail = (ImageView) gridView
                        .findViewById(R.id.grid_item_image);

                byte[] imageData = null;
                try {

                    final int THUMBNAIL_SIZE = 64;

                    FileInputStream fis = new FileInputStream(FILE_PATH
                            + fileList[position]);
                    Bitmap imageBitmap = BitmapFactory.decodeStream(fis);

                    Float width = new Float(imageBitmap.getWidth());
                    Float height = new Float(imageBitmap.getHeight());
                    Float ratio = width / height;
                    imageBitmap = Bitmap.createScaledBitmap(imageBitmap,
                            (int) (THUMBNAIL_SIZE * ratio), THUMBNAIL_SIZE,
                            false);

                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                    imageData = baos.toByteArray();
                    imageThumbnail.setImageBitmap(imageBitmap);
                } catch (Exception ex) {

                }

            } else {
                gridView = (View) convertView;
            }

            return gridView;
        }

here is my Code for grid View adapter :

     ImageAdapter adapter = null; //ImageAdapter extends BaseAdapter
            if (fileList != null) {
                 adapter = new ImageAdapter(this, fileList);
                gridView.setAdapter(i);
            }

while after deleting if I do :

adapter.notifyDataChanged();
grid.invalidateViews();

compiler complains to make the adpater as the “final” but if i make it “final” , it complains that i cant make adapter final as it will not allow the below line to happen :

adapter = new ImageAdapter(this, fileList);

Moreover I couldn’t find the implementation notifyDataChanged .There is notifyDataSetChanged,notify, notifyAll and notifyDataSetInvalidated but no notifyDataChanged.

I think Intent.ACTION_MEDIA_MOUNTED is for all the images/files located on the external sd card and not for the phone filesystem.is that correct.

How can I achieve it. Plz advice.

Rgds,
Softy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:59:04+00:00Added an answer on June 1, 2026 at 11:59 am

    You should look at :

    adapter.notifyDataSetChanged();
    grid.invalidateViews();
    

    It will notified the adapter that something changed, and redraw the grid..

    Concerning ,ACTION_MEDIA_MOUNTED the documentation says :
    External media is present and mounted at its mount point. The path to the mount point for the removed media is contained in the Intent.mData field. The Intent contains an extra with name “read-only” and Boolean value to indicate if the media was mounted read only.

    http://developer.android.com/reference/android/content/Intent.html#ACTION_MEDIA_MOUNTED

    So I guess you’re right on this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to delete the all but the most recent 3,000 items in
I am trying to delete checked items in my list view my app. The
I am trying to delete all the items in my Hashtable with this code
I am trying to manipulate SharePoint's default calendar to add, edit and delete items
i am trying to delete some files using a batch file.. (winxp) my problem
I'm trying to delete old SVN files from directory tree. shutil.rmtree and os.unlink raise
In Java I'm trying to delete a ftp directory. But if it's not empty,
I'm trying to delete items from a ListView using a custom adapter which extends
I am trying to delete an item from a folder somewhere, and I need
I'm trying to delete a li item using jquery, but its not working. Here's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.