开发者

Android : Monitoring folder activity

开发者 https://www.devze.com 2023-01-22 05:38 出处:网络
I want to create an app which would monitor changes to data in a folde开发者_StackOverflow中文版r on SD card.

I want to create an app which would monitor changes to data in a folde开发者_StackOverflow中文版r on SD card. For example if a file is put in a folder, as soon as file is copied, my app would send this file to server and delete this file. Is it possible to do this?

Thanks.


I think you can use android.os.FileObserver which is available since API Level 1. Source: http://developer.android.com/reference/android/os/FileObserver.html


I looks like there is no system-wide "FileSystemMonitor" you could connect to.

So you have to write it yourself. You could for example receive the ACTION_TIME_TICK broadcast and check the filesystem for changes yourself every minute using the normal java File classes.

0

精彩评论

暂无评论...
验证码 换一张
取 消