Page 1 of 1

SUG: run media scanner when modifying files on sdcard

Posted: 2011-07-31, 16:28 UTC
by DRockstar
I frequently add .nomedia files to sdcard directories, and it would be nice to have Total Commander force a new media scan when modifying files on the sdcard... I currently have to return to astro file manager when adding .nomedia files, since it forces a new media scan.

Thank you!

Posted: 2011-08-01, 08:07 UTC
by ghisler(Author)
This is indeed on my to do list. However, I really don't know yet how I should implement it. The following problems remain:
1. For which files should I call it? How do I know which files are media files and which not?
2. When should I call it? After each copied/moved file, after a lengthy file operation is complete, or only when the user presses a button?
3. How much does it affect the copying speed? Does the media player re-build its complete media database after each call? That would cause an enormous perfomance hit.

Unfortunately Android documentation is very bad for this, but maybe anyone has some clues about this problem...

Posted: 2011-08-04, 06:50 UTC
by matixx
Hallo, ich habe dasselbe Problem auf meinem Gingerbread Desire S.

Jedesmal wenn ich Dateien (egal welche) auf die SD-Karte kopiere, werden diese in den entsprechenden Anwendungen nicht angezeigt. Ich helfe mir derzeit mit einem Widget aus der APP "Extended Controls", welches manuell einen Mediascan auslöst.

zu 1. imo für jedes File
zu 2. wahlweise:
-nach jedem Kopiervorgang auf SD (also bei 50 zu kopierenden Files erst nach dem 50.
-beim Schliessen von TC
-beim Wechsel in andere Anwendungen (wenn das überhaupt ein Unterschied ist zu "Schliessen von TC)
-manuell per Button

zu3. das müsste man dann testen.

Link to possible solution...

Posted: 2011-09-16, 15:44 UTC
by DRockstar
Figured this may help, at least I link a possible code solution that could be easily called after any file operation. Hopefully this will work, I'm sure a solution would make everyone happy, that want their sdcard rescanned after file operations...

http://groups.google.com/group/android-developers/browse_thread/thread/c1a385226f3df482#

I'm currently using Total Commander RC1, and would love to see the scanner run when renaming folders or modifying files on the sdcard.

Other posts seem to indicate that the scanner may run after copy operations, I'll try that, but it's still won't run after renaming a folder on the sdcard. I have now tried copying photos between sdcard folders, and the scanner still doesn't run... hopefully that link will give you a simple and elegant solution :)

Thank you, and I hope this helps!

Posted: 2011-09-16, 15:54 UTC
by ghisler(Author)
TC already calls this ACTION_MEDIA_MOUNTED intent now when renaming folders, deleting or moving files anywhere on /sdcard or /mnt/sdcard, at the end of the file operation (when the progress dialog is removed).

It doesn't call it when adding files, then it informs the media database directly about each file. However, I will change that in the next beta, and only call ACTION_MEDIA_MOUNTED.