2014-10-11 2 views
0

및 Iam은 현재 사용자 연락처 을 동기화하는 안드로이드 응용 프로그램에서 작업 중이며 해당 사용자를 데이터베이스에서 검색하여 사용자의 친구로 표시합니다. 이것은 whatsapp와 매우 유사한 기술을 사용합니다. 새벽이에요. 누구든지 나를 도울 수 있다면 아주 친절합니다. 어디에서 시작해야하는지 알려주세요. 또한 제게이 말에 대한 제발 좀주세요. 도움이 될만한 도움이 필요합니다. 도움을 청하십시오. :-) 사전에 Thaks))) Contacts Provider데이터베이스 전화 안드로이드 응용 프로그램

에서

답변

0

시작 궁극적으로 당신은 위의 코드는 커서

에 아래의 인터페이스를 사용하여 이름을 가진 모든 전화 번호를 retrives

new CursorLoader(getActivity(), 
       contentUri, 
       ContactMobileNumbQuery.PROJECTION, 
       ContactMobileNumbQuery.SELECTION, 
       null, 
       ContactMobileNumbQuery.SORT_ORDER); 

사용해야합니다

/** 
* This interface defines constants used by mobile number retrieval queries. 
*/ 
public interface ContactMobileNumbQuery{ 
    final static int QUERY_ID = 1; 

    //A Content Uri for Phone table 
    final static Uri CONTENT_URI = Phone.CONTENT_URI; 

    //The search or filter query Uri 
    final static Uri FILTER_URI = Phone.CONTENT_FILTER_URI; 

    // The selection clause for the CursorLoader query. The search criteria defined here 
    // restrict results to contacts that have a phone number and display name. 
    // Notice that the search on the string provided by the user is implemented by appending 
    // the search string to CONTENT_FILTER_URI. 
    final static String SELECTION = Phone.HAS_PHONE_NUMBER + "=1" + " AND " + Phone.DISPLAY_NAME_PRIMARY + "<>''"; 

    // The desired sort order for the returned Cursor - Order by DISPLAY_NAME_PRIMARY 
    //in Ascending with case insensitively 
    final static String SORT_ORDER = Phone.DISPLAY_NAME_PRIMARY + " COLLATE NOCASE ASC"; 

    // The projection for the CursorLoader query. This is a list of columns that the Contacts 
    // Provider should return in the Cursor. 
    final static String[] PROJECTION = { 

     // The contact's row id 
     Phone._ID, 

     // the Contacts table contains DISPLAY_NAME_PRIMARY, which either contains 
     // the contact's displayable name or some other useful identifier such as an 
     // email address. 
     Phone.DISPLAY_NAME_PRIMARY, 

     // A pointer to the contact that is guaranteed to be more permanent than _ID. Given 
     // a contact's current _ID value and LOOKUP_KEY, the Contacts Provider can generate 
     // a "permanent" contact URI. 
     Phone.LOOKUP_KEY, 

     //Phone number of the contact 
     Phone.NUMBER, 
    }; 
    // The query column numbers which map to each value in the projection 
    final static int ID = 0; 
    final static int DISPLAY_NAME = 1; 
    final static int LOOKUP_KEY = 2; 
    final static int NUMBER = 3; 
} 

동기 로직을 ​​별도로 작성해야합니다. 그것을 시도하고 귀하의 의견을 게시 :)

+0

헥타르 내가 많이 보자 :-))))))))))))))))))))) – user3781907

+0

로 표시 올바른 답변 정말 문제를 해결하는 경우 :-) – Sathish

관련 문제