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 8527039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:26:36+00:00 2026-06-11T08:26:36+00:00

i would like sort the call logs by cached name. The cached name can

  • 0

i would like sort the call logs by cached name. The cached name can be null.
So in the case of a null cached name, i would like to have the phone number for an alias.

in sqlite, there is the ifnull() function.
ifnull details

I try :

String[] projections = new String[] { Calls._ID, Calls.NUMBER, Calls.DATE, Calls.TYPE, Calls.DURATION, "ifnull("+Calls.CACHED_NAME+","+Calls.NUMBER+") as display_name" };

Cursor cursor_call = ctx.getContentResolver().query(URI_CALL_LOGS,
                    projections,
                    null,
                    null,
                    null);

But i have an error with my use of ifnull an i don’t find a sample of this function.

java.lang.IllegalArgumentException: Invalid column ifnull(name,number) as display_name

  • 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-06-11T08:26:37+00:00Added an answer on June 11, 2026 at 8:26 am

    Because of the way you’re creating the query, things like parentheses are being auto-escaped to prevent SQL-injection attacks.

    In situations where you have direct access to the raw DB (not through a contentProvider), you can use a SQLiteDatabase.rawQuery, like so:

    myDB.rawquery(“select * from a, b where a.id=b.someid”, null);

    But in this case it looks like you want to access the contact app’s call_log database, which you can only do through the provided ContentResolver. Since it’s intentionally designed to only let you send values and not SQL commands as variables, ifnull(…) isn’t going to work, and you’ll need to choose between name and number using logic when you’re pulling data from the cursor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write some sort of API such that I can call
I have an array which i would like to sort it based on values
I have an array which i would like to sort it based on values
I have an array that I would like to sort using a date field
I have a very large multidimensional array and I would like to sort it
I have an array of appointment objects, and I would like to sort by
If I have a list of elements I would like to sort, Java offers
I have a NSMutableArray generated by XMLParser , I would like to sort the
I have an array of objects in JavaScript. I would like to sort them
I've two questions: I would like to know what sort of variable types can

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.