SUG: run media scanner when modifying files on sdcard

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
DRockstar
Junior Member
Junior Member
Posts: 5
Joined: 2011-07-30, 23:50 UTC

SUG: run media scanner when modifying files on sdcard

Post 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!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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...
Author of Total Commander
https://www.ghisler.com
User avatar
matixx
Power Member
Power Member
Posts: 1117
Joined: 2003-03-21, 02:37 UTC
Location: ....

Post 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.
DRockstar
Junior Member
Junior Member
Posts: 5
Joined: 2011-07-30, 23:50 UTC

Link to possible solution...

Post 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!
Last edited by DRockstar on 2011-09-16, 15:56 UTC, edited 1 time in total.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post 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.
Author of Total Commander
https://www.ghisler.com
Post Reply