[android-developers] Re: how to get notified(or Listen) for the changes in SD card

2009-08-14 Thread Mingli Wang
try FileObserver, it may help u

--~--~-~--~~~---~--~~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to get notified(or Listen) for the changes in SD card

2009-08-13 Thread Dianne Hackborn
http://developer.android.com/reference/android/os/FileObserver.html

But trying to watch for any change on any file is potentially extremely
expensive, since you need to be monitoring every single directory on the
file system, and updating what you are monitoring as directories are created
or removed.

This is just a fundamental aspect of how file monitoring works on Linux, so
there is not much to do about it.  I would strongly suggest trying to find
some other approach that does not require monitoring the entire file system.
:}

On Thu, Aug 13, 2009 at 12:36 PM, Casper Bang  wrote:

>
> Filesystem monitoring is only provided in Java in the NIO2 stuff
> coming with Java 7. Android supports a subset of Java 6 so perhaps you
> can port this over yourself by looking at their source. As far as I
> know though, even the NIO2 will often need to use constant polling
> which would absolutely kill the battery life of an Android device I
> think.
>
> So the real question is whether it's possible to hook into some native
> Android services and be notified regarding writes to /sdcard but I
> fear, if even possible, this require a rooted phone.
>
> /Casper
>
> On 13 Aug., 21:05, "Mapara,Harshit Nitinkumar" 
> wrote:
> > Hi All,
> >
> > I am creating an app and the requirement is - I have to listen to the
> > SD card for new data comes in.
> >
> > Whenever a new file is downloaded into SD card , I want to be notified.
> > (or say , I want to listen for changes)
> >
> > I searched, but can't get any useful help.
> >
> > Please help me in this issue.
> >
> > Any code sample, link will be nice to have.
> >
> > Thanks
> > Harshit
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to get notified(or Listen) for the changes in SD card

2009-08-13 Thread Harshit Mapara

Can you guys please tell me, how do I use intent - ACTION_MEDIA_EJECT?

How do I get notified if Media card(sd card) is ejected or mounted ?

I came to know of using this by intent action and broad cast receiver,
but dont know how to do this actually.

Thanks

On Aug 13, 12:36 pm, Casper Bang  wrote:
> Filesystem monitoring is only provided in Java in the NIO2 stuff
> coming with Java 7. Android supports a subset of Java 6 so perhaps you
> can port this over yourself by looking at their source. As far as I
> know though, even the NIO2 will often need to use constant polling
> which would absolutely kill the battery life of an Android device I
> think.
>
> So the real question is whether it's possible to hook into some native
> Android services and be notified regarding writes to /sdcard but I
> fear, if even possible, this require a rooted phone.
>
> /Casper
>
> On 13 Aug., 21:05, "Mapara,Harshit Nitinkumar" 
> wrote:
>
>
>
> > Hi All,
>
> > I am creating an app and the requirement is - I have to listen to the
> > SD card for new data comes in.
>
> > Whenever a new file is downloaded into SD card , I want to be notified.
> > (or say , I want to listen for changes)
>
> > I searched, but can't get any useful help.
>
> > Please help me in this issue.
>
> > Any code sample, link will be nice to have.
>
> > Thanks
> > Harshit
--~--~-~--~~~---~--~~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to get notified(or Listen) for the changes in SD card

2009-08-13 Thread Casper Bang

Filesystem monitoring is only provided in Java in the NIO2 stuff
coming with Java 7. Android supports a subset of Java 6 so perhaps you
can port this over yourself by looking at their source. As far as I
know though, even the NIO2 will often need to use constant polling
which would absolutely kill the battery life of an Android device I
think.

So the real question is whether it's possible to hook into some native
Android services and be notified regarding writes to /sdcard but I
fear, if even possible, this require a rooted phone.

/Casper

On 13 Aug., 21:05, "Mapara,Harshit Nitinkumar" 
wrote:
> Hi All,
>
> I am creating an app and the requirement is - I have to listen to the
> SD card for new data comes in.
>
> Whenever a new file is downloaded into SD card , I want to be notified.
> (or say , I want to listen for changes)
>
> I searched, but can't get any useful help.
>
> Please help me in this issue.
>
> Any code sample, link will be nice to have.
>
> Thanks
> Harshit
--~--~-~--~~~---~--~~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to get notified(or Listen) for the changes in SD card

2009-08-13 Thread Roman ( T-Mobile USA)

You might want to look at the following java libraries and see whether
you can port one of them to Android.

http://www.rgagnon.com/javadetails/java-0617.html

Another way might be to execute system commands like stat (for which
you have to be root which makes it more complicated to use it from SDK
level)

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.


On Aug 13, 12:05 pm, "Mapara,Harshit Nitinkumar" 
wrote:
> Hi All,
>
> I am creating an app and the requirement is - I have to listen to the
> SD card for new data comes in.
>
> Whenever a new file is downloaded into SD card , I want to be notified.
> (or say , I want to listen for changes)
>
> I searched, but can't get any useful help.
>
> Please help me in this issue.
>
> Any code sample, link will be nice to have.
>
> Thanks
> Harshit
--~--~-~--~~~---~--~~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---