If I save a file to the external storage on ICS, how soon should I be able to see it from my computer? Two or three weeks is what I am seeing.
And what if include a .nomedia file in a folder above this one? Does that mean I will never ever see it?
Perhaps I missed it, but I am not seeing good documentation about the media scanner. Nowhere do I see it mentioned that the media scanner scans any non media files, but that fact has been mentioned in this forum by reputable individuals.
I see this note in storage options:
Hiding your files from the Media Scanner
Include an empty file named.nomedia in your external files directory (note the dot prefix in the filename). This will prevent Android's media scanner from reading your media files and including them in apps like Gallery or Music.
This note does not say "this will prevent you from seeing any new files when browsing the storage from your desktop computer". But does it?
I really do want to hide files from showing up in Gallery or Music, and I certainly don't want to make the media scanner work overtime on my non media files. But I don't fully understand the consequences of having a .nomedia file, or any other reason why these files would be invisible.
Has anyone else seen this behavior? It is 100 percent reproducible. I write a file using a FileOutputStream. I use a file explorer on the device and I see the file. It has 9 files in the folder. I browse the folder from My Computer where it says "Galaxy Nexus". The same folder has 8 files. The file in question is not there.
On Monday, August 13, 2012 11:28:52 AM UTC-7, Nathan wrote:
> If I save a file to the external storage on ICS, how soon should I be able > to see it from my computer? > Two or three weeks is what I am seeing.
> And what if include a .nomedia file in a folder above this one? Does that > mean I will never ever see it?
> Perhaps I missed it, but I am not seeing good documentation about the > media scanner. Nowhere do I see it mentioned that the media scanner scans > any non media files, but that fact has been mentioned in this forum by > reputable individuals.
> I see this note in storage options:
> Hiding your files from the Media Scanner
> Include an empty file named.nomedia in your external files directory > (note the dot prefix in the filename). This will prevent Android's media > scanner from reading your media files and including them in apps like > Gallery or Music.
> This note does not say "this will prevent you from seeing any new files > when browsing the storage from your desktop computer". But does it?
> I really do want to hide files from showing up in Gallery or Music, and I > certainly don't want to make the media scanner work overtime on my non > media files. But I don't fully understand the consequences of having a > .nomedia file, or any other reason why these files would be invisible.
You are supposed to tell the media scanner about the new file yourself, or
else it might only be scanned after the next reboot.
14.08.2012 0:56 пользователь "Nathan" <nathan.d.mel...@gmail.com> написал:
> Has anyone else seen this behavior? It is 100 percent reproducible. I
> write a file using a FileOutputStream.
> I use a file explorer on the device and I see the file. It has 9 files in
> the folder.
> I browse the folder from My Computer where it says "Galaxy Nexus". The
> same folder has 8 files. The file in question is not there.
> What is happening?
> Nathan
> On Monday, August 13, 2012 11:28:52 AM UTC-7, Nathan wrote:
>> If I save a file to the external storage on ICS, how soon should I be
>> able to see it from my computer?
>> Two or three weeks is what I am seeing.
>> And what if include a .nomedia file in a folder above this one? Does that
>> mean I will never ever see it?
>> Perhaps I missed it, but I am not seeing good documentation about the
>> media scanner. Nowhere do I see it mentioned that the media scanner scans
>> any non media files, but that fact has been mentioned in this forum by
>> reputable individuals.
>> I see this note in storage options:
>> Hiding your files from the Media Scanner
>> Include an empty file named.nomedia in your external files directory
>> (note the dot prefix in the filename). This will prevent Android's media
>> scanner from reading your media files and including them in apps like
>> Gallery or Music.
>> This note does not say "this will prevent you from seeing any new files
>> when browsing the storage from your desktop computer". But does it?
>> I really do want to hide files from showing up in Gallery or Music, and I
>> certainly don't want to make the media scanner work overtime on my non
>> media files. But I don't fully understand the consequences of having a
>> .nomedia file, or any other reason why these files would be invisible.
>> Nathan
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
The easiest thing you can do is to call static
MediaScannerConnection.scanFile.
If you need to know when the scanning completes, you can implement
MediaScannerConnection, call connect, then call scanFile...
I have to say that making apps responsible for keeping the OS's data
structures up to date is quite a novel idea -- I guess it's due to the
limitations of the Linux kernel's file system change watching
capability.... AFAIK, it can't watch changes in sub-directories, so setting
a trigger on /mnt/sdcard in some system service won't work...
So -- you gotta do whatcha gotta do :)
> And does the .nomedia file matter?
According to the docs, it makes the media scanner ignore the directory. Not
sure if it has an effect on the scans you initiate yourself...
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> The easiest thing you can do is to call static > MediaScannerConnection.scanFile.
Well, that requires API 8.
Could I call
MediaScannerConnection conn = new MediaScannerConnection(this,null); conn.scanfile(filepath,mimetype);
That appears to work all the way back to API 1 - but is that too easy?
> If you need to know when the scanning completes, you can implement > MediaScannerConnection, call connect, then call scanFile...
Not as curious about that.
> I have to say that making apps responsible for keeping the OS's data > structures up to date is quite a novel idea
I think it is silly too - but not your fault.
> And does the .nomedia file matter?
> According to the docs, it makes the media scanner ignore the directory. > Not sure if it has an effect on the scans you initiate yourself...
So that is still a maybe. The documentation says that *media applications* ignore the directory. It doesn't say if the media scanner, which now scans all files, ignores it too. File explorer apps don't appear to ignore the path.
>> The easiest thing you can do is to call static MediaScannerConnection.**
>> scanFile.
> Well, that requires API 8.
But you only truly need it for MTP at API 14 and higher.
Or for 2.* in some cases (like getting image files to show up in the
gallery app).
> Could I call
> MediaScannerConnection conn = new MediaScannerConnection(this,null);
> conn.scanfile(filepath,mimetype);
Not like that.
> That appears to work all the way back to API 1 - but is that too easy?
You need to call connect() first, and only when it's done connecting to the
system service can you call scanFile. Don't forget to call disconnect when
done.
I pasted a bit of code here, hopefully it makes sense:
>> According to the docs, it makes the media scanner ignore the directory.
>> Not sure if it has an effect on the scans you initiate yourself...
> So that is still a maybe. The documentation says that *media applications*
> ignore the directory. It doesn't say if the media scanner, which now scans
> all files, ignores it too. File explorer apps don't appear to ignore the
> path.
A file manager type app most likely uses plain file system calls.
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>> > The easiest thing you can do is to call static
>> > MediaScannerConnection.scanFile.
>> BTW, this method never closes the connection it opens, so you will get
>> 'leaked service connection' (or some such) warnings in logcat if yo use
>> it.
> Hmm, there is a call to mConnection.disconnect in ClientProxy, line 204:
It's been there at least since GB. Looks like it should get
closed, so it looks like my assumption is (mostly?) wrong.
> It won't trigger if scanning a particular path element doesn't result in
> onScanCompleted(), though -- wonder if it can?
Not sure, but here's one warning I got recently, and I've had reports of this
before. This is for scanning a single file.
Service com.github.andlyticsproject.io.ExportService has leaked
ServiceConnection android.media.MediaScannerConnection@4149279 that
was originally bound here
android.app.ServiceConnectionLeaked: Service
com.github.andlyticsproject.io.ExportService has leaked
ServiceConnection android.media.MediaScannerConnection@4149279 that
was originally bound here
at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:965)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859)
at android.app.ContextImpl.bindService(ContextImpl.java:1216)
at android.app.ContextImpl.bindService(ContextImpl.java:1208)
at android.content.ContextWrapper.bindService(ContextWrapper.java:394)
at android.media.MediaScannerConnection.connect(MediaScannerConnection.java:11 6)
at android.media.MediaScannerConnection.scanFile(MediaScannerConnection.java:2 35)
at com.github.andlyticsproject.io.MediaScannerWrapper.scanFile(MediaScannerWra pper.java:15)
at com.github.andlyticsproject.util.Utils.scanFile(Utils.java:81)
at com.github.andlyticsproject.io.ExportService.exportStats(ExportService.java :102)
at com.github.andlyticsproject.io.ExportService.onHandleIntent(ExportService.j ava:71)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:6 5)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
> On Tue, Aug 14, 2012 at 4:47 PM, Kostya Vasilyev <kmans...@gmail.com>
> wrote:
> > Hmm, there is a call to mConnection.disconnect in ClientProxy, line 204:
> It's been there at least since GB. Looks like it should get
> closed, so it looks like my assumption is (mostly?) wrong.
> > It won't trigger if scanning a particular path element doesn't result in
> > onScanCompleted(), though -- wonder if it can?
> Not sure, but here's one warning I got recently, and I've had reports of
> this
> before. This is for scanning a single file.
> Service com.github.andlyticsproject.io.ExportService has leaked
> ServiceConnection android.media.MediaScannerConnection@4149279 that
> was originally bound here
> android.app.ServiceConnectionLeaked: Service
> com.github.andlyticsproject.io.ExportService has leaked
> ServiceConnection android.media.MediaScannerConnection@4149279 that
> was originally bound here
Funny. When in doubt, trust the logs, ignore the code, I guess :)
I have developed a file explorer (Android Tuner if you want to test this) and got report that file moved/copied did not appear in gallery or other apps, (starting with ICS I think).
So I added the scanning/deleting of all files manipulated by the file explorer, so that they would also appear in MTP on my computer. But now, Gallery gets updated no matter what, as explained in this issue: http://code.google.com/p/android/issues/detail?id=24162
Obviously the ".nomedia" is no longer working as it should. Media scanner is now registering all files on storage (for MTP purposes), but forget to remove the nomedia content from the media section. A media DB containing non media files, is this a joke?
I personally find very odd to leave apps responsible for updating OS data structure. And again, dev will take the blame for one more bug in the OS, because there's no win-win here for us: either we scan all content and gallery apps get messed up, or we don't and MTP get messed up!
On Tuesday, August 14, 2012 1:28:52 AM UTC+7, Nathan wrote:
> If I save a file to the external storage on ICS, how soon should I be able > to see it from my computer? > Two or three weeks is what I am seeing.
> And what if include a .nomedia file in a folder above this one? Does that > mean I will never ever see it?
> Perhaps I missed it, but I am not seeing good documentation about the > media scanner. Nowhere do I see it mentioned that the media scanner scans > any non media files, but that fact has been mentioned in this forum by > reputable individuals.
> I see this note in storage options:
> Hiding your files from the Media Scanner
> Include an empty file named.nomedia in your external files directory > (note the dot prefix in the filename). This will prevent Android's media > scanner from reading your media files and including them in apps like > Gallery or Music.
> This note does not say "this will prevent you from seeing any new files > when browsing the storage from your desktop computer". But does it?
> I really do want to hide files from showing up in Gallery or Music, and I > certainly don't want to make the media scanner work overtime on my non > media files. But I don't fully understand the consequences of having a > .nomedia file, or any other reason why these files would be invisible.