how to retrieve (filtered) contacts

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

how to retrieve (filtered) contacts

Postby chaoz1336 » Fri Sep 18, 2009 11:08 am

Hi Guys...

how do I get a List of all contacts that have a Faxnumber? (Undepending wether work/home fax)
otherwise I found

public static final int TYPE_FAX_HOME = 5 but I dont know how to use this =/
thx a lot in advance!

my code: (I ONLY get the default-phoneNumber, I have to use a filter anyhow)


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String columns[] = new String[] {People.NAME, People.NUMBER};
  2.  
  3.         Cursor c = managedQuery(People.CONTENT_URI, columns, null, null, Contacts.People.DEFAULT_SORT_ORDER);
  4.  
  5.  
  6.  
  7.         if(c.moveToFirst())
  8.  
  9.         {
  10.  
  11.             String name = null;
  12.  
  13.             String phoneNo = null;
  14.  
  15.             int i = 0;
  16.  
  17.            
  18.  
  19.             do
  20.  
  21.             {
  22.  
  23.                 name = c.getString(c.getColumnIndex(People.NAME));
  24.  
  25.                 phoneNo = c.getString(c.getColumnIndex(People.NUMBER));
  26.  
  27.  
  28.  
  29.                 System.out.println(" Name = " + name+" Number = "+phoneNo);
  30.  
  31.                
  32.  
  33.                 if(i<c.getCount())
  34.  
  35.                 {
  36.  
  37.                     i++;
  38.  
  39.                 }
  40.  
  41.             } while (c.moveToNext());
  42.  
  43.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Top

Postby mastix » Sun Sep 20, 2009 10:02 am

Hi,

see the app I'm currently developing:

http://code.google.com/p/web2sms4androi ... ivity.java

In this class, I've implemented an inner class called "RecipientsAdapter". This should pretty much do everything you need/want. :)

I hope that this was a help for you.

Greetz,

Sascha
mastix
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Sep 20, 2009 9:57 am

Postby chaoz1336 » Mon Sep 21, 2009 9:50 am

Hi Sascha,

thx a lot for the fast reply, great stuff... ^^
but I got some questions:

your code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. s.append("))");
  3.  
  4. s.append(")) AND type = "); s.append(Phones.TYPE_MOBILE);
  5.  
  6. wherePhone = s.toString();
  7.  
  8. return this.mContentResolver.query(Phones.CONTENT_URI, this.projectionPhone, wherePhone, null, SORT_ORDER);
  9.  
  10.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


...when I use "wherePhone = "type = 4";" then I get all contacts that use "Work_Fax" as their primary number... BUT I want to find out wether the contact has a FaxNumber, even if its not the primary number.


It's that hell confusing o_o

It'd be very very very great if u could help me anyhow =)
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Postby chaoz1336 » Thu Sep 24, 2009 8:57 am

...mastix? any idea? =/
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Postby chaoz1336 » Fri Nov 27, 2009 5:03 pm

anyone?
chaoz1336
Experienced Developer
Experienced Developer
 
Posts: 90
Joined: Wed Dec 10, 2008 5:19 pm

Postby Davide » Wed Dec 02, 2009 2:18 am

Do you need to make a sql code?
Davide
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Mon Oct 19, 2009 12:05 pm
Location: Italy

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Google [Bot] and 3 guests