안드로이드 개발 질문/답변
(글 수 45,052)
안드로이드 전화번호부를 가져와서 sqlite로 다른 DB를 만들어서 저장하고 싶은데
연락처가 500건 정도 되니 너무 느리네요 좋은 방법이 없을까요????
//소스의 일부분 입니다.
try{
Uri uContactsUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String strProjection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME;
phoneCursor = getContentResolver().query(uContactsUri, null, null, null, strProjection);
phoneCursor.moveToFirst();
int nameColumn = phoneCursor.getColumnIndex(Phone.DISPLAY_NAME);
int phoneColumn = phoneCursor.getColumnIndex(Phone.NUMBER);
sqldb = kcdb.getWritableDatabase();
do{
//전화번호와 이름을 구한다.
name=phoneCursor.getString(nameColumn);
phoneNumber = phoneCursor.getString(phoneColumn);
first="1";
sqldb.execSQL("INSERT INTO userdb VALUES (null,'"+first+"','"+name+"','"+phoneNumber+"');");
}while(phoneCursor.moveToNext());
}
Uri uContactsUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String strProjection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME;
phoneCursor = getContentResolver().query(uContactsUri, null, null, null, strProjection);
phoneCursor.moveToFirst();
int nameColumn = phoneCursor.getColumnIndex(Phone.DISPLAY_NAME);
int phoneColumn = phoneCursor.getColumnIndex(Phone.NUMBER);
sqldb = kcdb.getWritableDatabase();
do{
//전화번호와 이름을 구한다.
name=phoneCursor.getString(nameColumn);
phoneNumber = phoneCursor.getString(phoneColumn);
first="1";
sqldb.execSQL("INSERT INTO userdb VALUES (null,'"+first+"','"+name+"','"+phoneNumber+"');");
}while(phoneCursor.moveToNext());
}




setTransactionSuccessful()
endTransaction()
찾아보세요..