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

  • Home
  • SEARCH
  • 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 7053075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:27:39+00:00 2026-05-28T03:27:39+00:00

why do we need to set a projectionMap with SQLiteQueryBuilder ? For example, we

  • 0

why do we need to set a projectionMap with SQLiteQueryBuilder ? For example, we set this HashMap :

sNotesProjectionMap = new HashMap<String, String>();
sNotesProjectionMap.put(Notes._ID, Notes._ID);
sNotesProjectionMap.put(Notes.TITLE, Notes.TITLE);
sNotesProjectionMap.put(Notes.NOTE, Notes.NOTE);
sNotesProjectionMap.put(Notes.CREATED_DATE, Notes.CREATED_DATE);
sNotesProjectionMap.put(Notes.MODIFIED_DATE, Notes.MODIFIED_DATE);

and in the “query”, we also specify the projection, selection etc. from the Activity, so what the point to do this hashmap first?

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(NOTES_TABLE_NAME);

    switch (sUriMatcher.match(uri)) {
    case NOTES:
        qb.setProjectionMap(sNotesProjectionMap);
        break;

    case NOTE_ID:
        qb.setProjectionMap(sNotesProjectionMap);
        qb.appendWhere(Notes._ID + "=" + uri.getPathSegments().get(1));
        break;

    //...
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);

    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}

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-28T03:27:39+00:00Added an answer on May 28, 2026 at 3:27 am

    You can check the documentation for setprojectionmap . It does translations from application column names to database columns. Hashmap will have the translation.

    The key in the map is the column name the application will use and the value is the column name in the database.

    They are identical in the NotePadProvider in your example, but they could differ if the name of a column in the database changed and you wanted to keep the change transparent to applications using the content provider.

    For example, if the database column name of the “title” field (which is stored in Notes.TITLE) changed to “content”, a new constant Notes.CONTENT could be created and the projection insertion would look like:

    sNotesProjectionMap = new HashMap<String, String>();
    ...
    sNotesProjectionMap.put(Notes.TITLE, Notes.CONTENT);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to set up this scenario: A SQL Server 2005 database will create
I need set Text with variable and I got error: Cannot invoke setText(String) on
I need to set custom variable name for every iteration. Why this isn't possible?
I need set to all app ToolTipService.ShowDurationProperty = 10000 this anwser HCL <Style TargetType=Control>
In a project I have put together, I need set up some JMS queues
Usually, we can set this value as a text, while what I need is
Need to set left margin to a button object programatically. This is the code
Need set zoom for camera preview...
I need Set collection, where its items will be identified by items class. Something
I need to set the height of every textbox on my form, some of

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.