Take a look at AccountManager docs:
http://developer.android.com/intl/en/reference/android/accounts/AccountManager.html

AccountManager supports the notion of authentication token, which is what I
think you need.

Cheers,
- Dmitri

On Wed, Jan 26, 2011 at 10:26 AM, L0rdAli3n <[email protected]
> wrote:

> Ok, I'm about to write the SyncAdapter part of my App.
>
> Due to the fact that I have a special case, I'm a little bit stuck:
>
> Additional to the username/password I need to store a URL on a per
> account base!
>
> How I'm supposed to store this extra information, attached to an
> account?
>
> Thanks for your help an patience Dmitri!
>
> On 23 Jan., 19:00, Dmitri Plotnikov <[email protected]> wrote:
> > Using ContentObserver for sync adapters does not sound like a good idea.
> >  There are several reasons for that:
> >
> > 1. Data change notifications are not delivered to processes that are not
> > running. So if your sync adapter is not running for one reason or another
> > (and the system kills processes when it needs resources), then you won't
> get
> > a notification.
> > 2. ContactsProvider sends only general "whole adapter" notifications,
> > meaning that when any data element in the database changes it sends a
> > notification to all observers regardless of what URIs they registered
> for.
> >  For example, somebody's presence in Talk changes - you will get a
> > notification.  Most of these notifications will have nothing to do with
> the
> > changes you need to sync, but there is no way for the adapter to tell.
> > 3. Having the sync adapter running at all times is a major waste of
> > resources.
> >
> > Fortunately, the sync framework is designed to overcome all these issues.
> >  SyncManager manages sync adapters, calls them at the best time from the
> > system's perspective, throttles their activities etc.  Sync adapters
> > themselves rely on RawContact.DIRTY flag and the
> > ContactsContract.CALLER_IS_SYNCADAPTER parameter to find and process
> > incremental changes.
> >
> > There are examples of how that's done.  The most comprehensive example is
> > probably the Exchange (IAS) sync adapter that you can find here:
> >
> > http://android.git.kernel.org/?p=platform/packages/apps/Email.git;a=t...
> >
> > Cheers,
> >
> > On Fri, Jan 21, 2011 at 11:57 PM, himanshu jain <[email protected]
> >wrote:
> >
> > > Hi Dmitri  ,@LordAli3n
> > > I have couple of questions please spare some time or guide me
> > > direction
> > > 1) Can we use syncAdapter to get data of a row of raw_contact table if
> > > that row has been affected (i.e added/deleted/edited). I know
> > > ContentObserver notify whenever raw_content table changes in
> > > onChange() method but we dont know which row has been changed ( to put
> > > this in another way if we add how would we know and if deleted we
> > > still get it through deleted flag in raw_contact table but how about
> > > edited one??).
> > > 2) when we get notification in ContentObserver can we fire requestSync
> > > (Account account, String authority, Bundle extras) to start Sync ??
> > > how we can get data of raw_contact affected by contact application
> > > using these to parameters .
> > > 3) Is sync started by ContentProvider API ?? whenever change to it
> > > happens ??. How?? does it pass any useful uri or data that has been
> > > changed in raw_contacts??.
> > > 4) How do we come to know if in the process of  syncing something went
> > > wrong?? does it started again automatically??.
> >
> > > thanks any help appreciated !!
> >
> > > On Jan 19, 7:31 am, BoD <[email protected]> wrote:
> > > > If I may intervene.
> > > > It seems to me that the OP wants to synchronize contacts using the
> > > > sync adapters APIs, and therefore wants to have his own account type,
> > > > and raw contacts in this account.
> >
> > > > But that means that when the user first starts using this app, this
> > > > account will be empty, and will synchronize... nothing.
> > > > Instead, they probably expect to synchronize the contacts already on
> > > > their phones (in the "local" account, or, more probably, in the gmail
> > > > account).
> >
> > > > --
> > > > BoD
> >
> > > > On Jan 19, 9:02 am, Dmitri Plotnikov <[email protected]> wrote:
> >
> > > > > I am sorry. I guess I just don't understand the requirements.  I
> > > thought you
> > > > > were writing a sync adapter.  Sync adapters all deal with their own
> > > > > accounts.  Google sync adapter deals with google accounts, exchange
> > > adapter
> > > > > with exchange accounts and so on.  If you are thinking of writing a
> > > sync
> > > > > adapter that would handle data already handled by some other sync
> > > adapter,
> > > > > it is probably a bad idea. The framework is not designed to have
> > > multiple
> > > > > sync adapters handling the same data: only one syncadapter can take
> > > > > advantage of data versioning. This why I suggested that if you are
> > > writing a
> > > > > sync adapter, you should introduce a new account type. This is how
> they
> > > are
> > > > > supposed to work by design.
> >
> > > > > Cheers,
> > > > > Dmitri
> > > > > On Jan 18, 2011 5:43 PM, "L0rdAli3n" <
> [email protected]>
> > > > > wrote:
> >
> > > > > > Thanks for your answer Dmitri!
> >
> > > > > > Could you explain in few words, how I can use the contacts the
> user
> > > > > > stored on his phone,
> > > > > > which in fact all have already an account_type, by introducing my
> own
> > > > > > accout_type?
> >
> > > > > > On 14 Jan., 16:26, Dmitri Plotnikov <[email protected]>
> wrote:
> > > > > >> I don't fully understand your requirements, but it shouldn't
> matter
> > > what
> > > > > >> _other_ data is in the contacts DB.  A sync adapter should only
> deal
> > > with
> > > > > >> its own data. Why not introduce a new account type for this
> purpose?
> >
> > > > > >> Cheers,
> > > > > >> Dmitri
> > > > > >> On Jan 14, 2011 5:16 AM, "L0rdAli3n" <
> > > [email protected]>
> > > > > >> wrote:
> >
> > > > > >> > Hey,
> >
> > > > > >> > I'm totally stuck with the ContactsContract-API. Point is that
> I
> > > want
> > > > > >> > only mess around with the Contacts saved in the "local"
> phonebook.
> > > But
> > > > > >> > it seems that every vendor but its own account_type for those
> > > > > >> > contacts.
> > > > > >> > And its even worse. The AccountManager isn't even aware of all
> > > > > >> > account_types?!?
> > > > > >> > For example on my HTC Desire with HTC Sense, the account_type
> all
> > > > > >> > local contacts are saved in is: com.htc.android.pcsc. But when
> I
> > > grab
> > > > > >> > a list of all available accounts from the AccountManager: This
> > > account
> > > > > >> > is not in the list!?
> > > > > >> > I also tested it on a Samsung Galaxy. Same here: The
> > > AccountManager is
> > > > > >> > not aware of the account_type used for local
> phonebookcontacts.
> >
> > > > > >> > The whole story is that I wan't to write a app to sync my
> locale
> > > > > >> > phonebook with OpenXchange.
> >
> > > > > >> > I guess I got that whole new ContactsContract-API wrong, but I
> > > don't
> > > > > >> > see any other way, then using RawContacts. Due to that I have
> to
> > > care
> > > > > >> > about the account_type, which is in fact a total mess.
> >
> > > > > >> > Hopefully someone can point me in the right direction. Every
> hint
> > > is
> > > > > >> > highly appreciated.
> >
> > > > > >> > --
> > > > > >> > You received this message because you are subscribed to the
> Google
> > > > > >> > Groups "Android Developers" group.
> > > > > >> > To post to this group, send email to
> >
> > > > > [email protected]>> > To unsubscribe from this
> > > group, send email to
> > > > > >> > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> ><android-developers%2Bunsubs
> > > [email protected]>
> >
> > > > > <android-developers%[email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> ><android-developers%252Bu
> > > [email protected]>
> >
> > > > > >> > For more options, visit this group at
> > > > > >> >http://groups.google.com/group/android-developers?hl=en
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> > > [email protected]
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> ><android-developers%2Bunsubs
> > > [email protected]>
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-developers?hl=en
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<android-developers%[email protected]>
> <android-developers%[email protected]<android-developers%[email protected]>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to