Pictures appearing multiple times – ICS

A few weeks ago I installed the new Android 4.0 – “Ice Cream Sandwich” on my Samsung Galaxy SII. There is no stable version yet so I took the experimental build of CyanogenMod 9. You’ll find the latest ROM here.
After using it for few days, maybe I did an upgrade to a newer version – can’t remember, the pictures in my albums appeared twice or more… I deleted the data of the gallery app, I manually checked the data of the gallery app with adb and I searched for .thumbnails and deleted them all. None of all these steps worked.
Finally I figured out that the Android media provider has a database with all pictures. There was the problem! As this is independent from the gallery app this phenomenon could appear on other galleries too… The media providers databases are located in /data/data/com.android.providers.media/databases. I was to lazy to correct the databases – I just wiped them all. The gallery app has a cache of the pictures which we need to clear otherwise the previews in the gallery are not longer corresponding with the actual pictures. After a restart the gallery app was scanning for new media on the phone and the multiple instances of pictures were gone! After the wipe of all media provider databases I guess Android has to re-scan for all other media files too, e.g. mp3s, videos, etc.
I wrote a script which is doing the wipe for you. You can download the script here.

adb push wipeMediaProvider.sh /data/local/tmp
adb shell
su
cd /data/local/tmp
chmod 777 /data/local/tmp/wipeMediaProvider.sh
./wipeMediaProvider.sh

Probably it’s easier to delete the databases yourself than use my script…

adb shell
su
cd /data/data/com.android.providers.media/databases
rm -r *
find /data -name *gallery3d* -exec rm -r {} \;
find /mnt -name *gallery3d* -exec rm -r {} \;

I don’t know if this is a general problem of Android 4.0 or if it’s only because of the experimental build. I currently have installed Android 4.0.3 – the build 01292012 and GApps 11.

Leave a Reply

Your email address will not be published. Required fields are marked *