[/data/contact.java]

   // BEGIN: 2010-04-21 lee.hyuntae @btb
    private static final ContentObserver sContactsObserver = new ContentObserver(new Handler()) {
        @Override
        public void onChange(boolean selfUpdate) {
         Log.d("foxil","contactObserver call invalidateCache()");
            invalidateCache();

            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                log("contact changed, invalidate cache");
            }
        }
    };
    // END: 2010-04-21 lee.hyuntae @btb

   public static void init(final Context context) {
        Cache.init(context);
        RecipientIdCache.init(context);

        // it maybe too aggressive to listen for *any* contact changes, and rebuild MMS contact
        // cache each time that occurs. Unless we can get targeted updates for the contacts we
        // care about(which probably won't happen for a long time), we probably should just
        // invalidate cache peoridically, or surgically.

        // BEGIN: 2010-04-21 lee.hyuntae @btb
        context.getContentResolver().registerContentObserver(
                Contacts.CONTENT_URI, true, sContactsObserver);
     }
     // END: 2010-04-21 lee.hyuntae @btb

; contentResolver에 db를 감시하는 contentObserver 메서드를 사용하면 리스너로 사용할 수 있다.


 

'old > sms_mms' 카테고리의 다른 글

소프트키보드 설정  (0) 2010.03.30
Vcard  (0) 2010.03.09
Posted by jazzlife
,