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 6214255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:50:40+00:00 2026-05-24T06:50:40+00:00

android remove or recycle images from gallery? Is it possible? How Can i do

  • 0

android remove or recycle images from gallery? Is it possible?

How Can i do this? (g is my gallery view)

I tried this:

private void exit() {
    g.setAdapter(null);

    for (int i=0; i< imgadapter.images.size(); i++) {
        if (imgadapter.images.get(i)!=null) {
            imgadapter.images.get(i).recycle();
            imgadapter.images.set(i, null);
        }
    }
    imgadapter.images.clear();
    System.gc();
}


08-05 09:09:19.671: ERROR/AndroidRuntime(1279): java.lang.NullPointerException
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.Gallery.makeAndAddView(Gallery.java:748)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.Gallery.layout(Gallery.java:625)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.Gallery.onLayout(Gallery.java:339)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1145)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.os.Looper.loop(Looper.java:130)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at android.app.ActivityThread.main(ActivityThread.java:3687)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at java.lang.reflect.Method.invokeNative(Native Method)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at java.lang.reflect.Method.invoke(Method.java:507)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279):     at dalvik.system.NativeStart.main(Native Method)
  • 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-05-24T06:50:41+00:00Added an answer on May 24, 2026 at 6:50 am

    It’s probably not a good idea to carpet-bomb your adapter and delete everything, regardless of whether or not it’s still in use. recycle is merciless and will delete your bitmap, even if it’s still in use.

    Since you’re using a Gallery, I would make use of Android’s built-in recycling mechanism for adapters.

    See how Adapter.getView takes a View parameter. If that’s not null, you are recycling an old view. That’s the perfect place for you to grab the bitmap from that old view (which you know will not be used anymore!) and recycle it. You can then use that view and re-populate it (rather than creating a new one).

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

Sidebar

Related Questions

Please explain how can I remove screen orientation from PhoneGap android application in eclipse.
I want to remove the font padding from an Android button? I've tried set
How can I remove a LCK file from /data/local/tmp in android when app starts?
Possible Duplicate: add and remove views in android dynamically? In Iphone, the view is
Does anyone know how I can remove the address bar from the Android browser
How can I remove the scroll bar from a ScrollView programmatically? setScrollBarStyle() only changes
I've followed THIS thread to remove the border that surrounds the Gallery, but the
How can I hide or remove the status bar in Android HoneyComb? Every time
How can I remove a button in Android, or make it invisible?
I am writing an android application where the user can add and remove fields

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.