Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ContactsDao {
- public List<Contact> getAll() {
- String sql = "select * from contacts as t left join contact_groups as r1 on (t._id = r1.contact_id) left join ontact_phone_numbers as r2 on (t._id = r2.contact_id)";
- Cursor result = // asking android for cursor.
- while (result.moveToNext()) {
- // Here inefficiency starts:
- // 1. get contact id
- // 2. check if entity for that id is already created:
- // 2.no: 1. create entity (new Contact()) and add to list
- 2. add contact related data (display name, etc) to entity from cursor
- // 2.yes: retrieve created entity from memory.
- // 3. get group id
- // 4. Check if entity for that group id is already created:
- // 4.no: create entity (ask groups dao, probably) and add it to contact's groups list
- // 4.yes: do nothing group already added.
- // 5. Do step 4 for phone numbers
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement