1. Check out our app, Forums for Android! Download and leave feedback here!

Proxy for ContentProvider

Discussion in 'Application Development' started by Kammerer, Mar 26, 2010.

  1. Kammerer

    Kammerer New Member
    Thread Starter
    5

    Mar 26, 2010
    1
    0
    5
    Problem: I want to add automatic phone number formatting. It means: when user insert new phone number, or change existing number "1122334455" Android should save in database formated value "(112) 233-44-55" (like in the iPhone ;) ).
    As I read in Android Documentation com.android.providers.contacts.ContactsProvider has two fields "NUMBER" and "NUMBER_KEY". NUMBER means formated phone number to display in "Contacts" application while NUMBER_KEY contains only numbers.
    I can write an application which would iterate over all phones in the contacts database and reformat phone numbers. But I'd like to have automatic formating. For this purpose my application should handle write requests to Contacts database. And when some phone number is changed/inserted application should apply phone formating.
    I think this could be done using some sort of proxy for a Contacts ContentProvider. This proxy should pass regular requests to default Contacts ContentProvider and do some work on writing/inserting requests. Is there such a thing at android platform?

    Another solution is to rewrite existing class com.android.providers.contacts.ContactsProvider. But this class differres for differrent Android versions. And some system update could brake my rewrited ContactsProvider.

    P.S. Sorry for my English. I hope idea is clear for you.
     

    Advertisement

Share This Page

Loading...