android remove or recycle images from gallery? Is it possible?
<p>android remove or recycle images from gallery? Is it possible?</p>

<p>How Can i do this? (g is my gallery view)</p>

<p>I tried this:</p>

<pre><code>private void exit() {
    g.setAdapter(null);

    for (int i=0; i&lt; 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)
</code></pre>
