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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:20:08+00:00 2026-05-27T19:20:08+00:00

I looked for this on SO and saw this(and others like it): sql direct

  • 0

I looked for this on SO and saw this(and others like it): sql direct way to get number of rows in table, however, Select is shown as a token as is count. I tried to use mDb.execSQL() but that only returns void. Any help on how to do this would be appreciated. The code is:
public int getRowNumber(){ return mDb.execSQL(“SELECT COUNT(*) FROM notes”);} I get an error that says “cannot return void result”.

  • 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-27T19:20:09+00:00Added an answer on May 27, 2026 at 7:20 pm

    The error you’re getting means your method can’t return void. execSQL itself returns a void, and you’re returning that same void from your own method which is declared to return an int:

    mDB.execSQL(...); // returns void
    return mDB.execSQL(...); // re-returns void
    
    public int foo() {
        return void; // error!
    }
    

    d.android.com link for reference.


    I know you already accepted, but here’s a quick & dirty test method that does what you sort of need to do:

        public int testCount() {
         Cursor c = m_db.rawQuery("select count(*) from mytable", null);
         int tst = 0;
         if (c.moveToNext()) {
             tst = c.getInt(c.getColumnIndex("count(*)"));
         }
         c.close();
         return tst;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently saw a bit of code that looked like this (with sock being
I saw a java function that looked something like this- public static<T> foo() {...}
I saw a line of C that looked like this: !ErrorHasOccured() ??!??! HandleError(); It
I've looked at this question: Select first instance only with XPath? But if I
I was going over C++0x. As i looked at tuple I saw this example.
I saw something like the following in our production code: select max(col_val) from table_name
so i have looked at a couple other questions like this and from what
I saw something like this in some graphics libs today, and it seems like
I saw this question asked a million times and none of the answers looked
I've looked this up a thousand times, and I always forget it, so, here

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.