Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:16:59+00:00 2026-05-20T18:16:59+00:00

Cursor cursor = resolver.query( Data.CONTENT_URI, DataQuery.PROJECTION, DataQuery.SELECTION, new String[] {String.valueOf(rawContactId)}, null); With PROJECTION being:

  • 0
Cursor cursor = resolver.query(
    Data.CONTENT_URI,
    DataQuery.PROJECTION,
    DataQuery.SELECTION,
    new String[] {String.valueOf(rawContactId)},
    null);

With PROJECTION being:

public static final String[] PROJECTION = new String[] {
    Data._ID,
    Data.MIMETYPE,
    Data.DATA1,
    Data.DATA2,
    Data.DATA3};

and SELECTION being:

public static final String SELECTION = Data.RAW_CONTACT_ID + "=?";

The rawcontactId does return values, I’ve made logs to check. To give it some context I’m working with Account sync. The goal here is for it to find the data columns for existing contacts and writing over them with any new data. I’m working from the following sample code provided by android: http://developer.android.com/resources/samples/SampleSyncAdapter/src/com/example/android/samplesync/platform/ContactManager.html

To summarize my problem, I have two contacts via this synced account which are added without any problems, but are not being able to be updated. Anyone have experience with this? Thanks.

EDIT: Here is my rawContact returning method

private static long lookupRawContact(ContentResolver resolver, String username) {
    Log.e("Looking up Raw Contact", username);
    long authorId = 0;
    Cursor cursor = resolver.query(
        Data.CONTENT_URI,
        UserIdQuery.PROJECTION,
        UserIdQuery.SELECTION,
        new String[] {username},
        null);

    try {
        if(cursor != null && cursor.moveToFirst()) {
            authorId = cursor.getLong(UserIdQuery.COLUMN_ID);
        }
    } finally {
        if(cursor != null) {
            cursor.close();
        }
    }
    return authorId;
}

The numbers I get back are like 3061. Here is the UserIdQuery class:

final private static class UserIdQuery {

    private UserIdQuery() {

    }

    public final static String[] PROJECTION = new String[] {RawContacts._ID};
    public final static int COLUMN_ID = 0;
    public static final String SELECTION = RawContacts.ACCOUNT_TYPE + "='" + 
        "com.tagapp.android" + "' AND " + RawContacts.SOURCE_ID + "=?";

}

And here is my constructor for a ContactSyncOperations class being used to add a new contact. The source id here is a username, the same as I call in my SELECTION argument.

public ContactSyncOperations(Context context, String username,
        String accountName, BatchOperationForSync batchOperation) {

    this(context, batchOperation);
    mBackReference = mBatchOperation.size();
    mIsNewContact = true;
    mValues.put(RawContacts.SOURCE_ID, username);
    mValues.put(RawContacts.ACCOUNT_TYPE, "com.tagapp.android");
    mValues.put(RawContacts.ACCOUNT_NAME, accountName);
    mBuilder = newInsertCpo(RawContacts.CONTENT_URI, true).withValues(mValues);
    mBatchOperation.add(mBuilder.build());
}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:16:59+00:00Added an answer on May 20, 2026 at 6:16 pm

    There was an error in the lookupRawContactId method, the rawcontactId long I was getting wasn’t the right one. It should have looked like this:

    private static long lookupRawContact(ContentResolver resolver, String username) {
        Log.e("Looking up Raw Contact", username);
        long authorId = 0;
        Cursor cursor = resolver.query(
            RawContacts.CONTENT_URI,
            UserIdQuery.PROJECTION,
            UserIdQuery.SELECTION,
            new String[] {username},
            null);
    
        try {
            if(cursor != null && cursor.moveToFirst()) {
                authorId = cursor.getLong(UserIdQuery.COLUMN_ID);
            }
        } finally {
            if(cursor != null) {
                cursor.close();
            }
        }
        return authorId;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

int columnIndexFromAddrCountry; public FavoritesActAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
I am using a Cursor in my stored procedure. It works on a database
In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN
Is it possible to set the cursor to 'wait' on the entire html page
I'd like my datagridview cursor to move right to the next column instead of
Is there a difference between Cursor.Current and this.Cursor (where this is a WinForm) in
How do you set the cursor position in a text field using jQuery? I've
X has the method XCreatePixmapCursor to create a cursor from a pixmap with a
What is the shortcut key for Run to cursor in Visual Studio 2008?
I am using SetCursor to set the system cursor to my own image. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.