Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173641
  • 博文数量: 47
  • 博客积分: 992
  • 博客等级: 准尉
  • 技术积分: 565
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-08 21:57
文章分类

全部博文(47)

文章存档

2019年(1)

2018年(1)

2017年(1)

2014年(6)

2013年(1)

2012年(2)

2011年(35)

我的朋友

分类: 嵌入式

2011-04-08 10:03:08

Android110408: FileObserver注记


Email:    zcatt@163.com
Blog    http://zcatt.blog.chinaunix.net
 
内容提要
FileObserver.以供备忘和参考。

声明
仅限学习交流,禁止商业用途。转载需注明出处。

版本记录
Date        Ver        Note
2011-04-08    0.1        Draft.  zcatt, Beijing
 
借助FileObserver可以得到访问文件/目录时的各种事件. 派生FileObserver子类必须实现onEvent()方法. 通常的调用过程.

    YourFileObserver  observer = new YourFileObserver(path, eventMask);
    ... ...
    observer.startWatching()
    ... ...
    // your proc
    ... ...
    observer.stopWatching()

有一点要特别注意, FileObserver有自己的特别线程, onEvent就运行在这个线程中, 因此要注意同步问题, 并且不要在onEvent()中执行太耗时的操作.  可以考虑使用Handler机制.

阅读(873) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~