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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:30:08+00:00 2026-06-17T16:30:08+00:00

i am trying to build an application that save data in sqlite database.i have

  • 0

i am trying to build an application that save data in sqlite database.i have a class that search in the database searching by VendorName and Date. The problem is i want it to display the MeterNumbers that was saved on the same Date . to what i have tried it only gives me the first result it get in the database, lets say i search for Tom that was saved on 01/01/2013, it supposed to display both metereNumbers of Tom that was saved on 01/01/2013

here is an example of my table in sqlite

VendorName Date MeterNumber

…Tom…. 01/01/2013 ……2098957438902

…Tom… 01/01/2013……..4786909876785

…Steven…18/01/2013………8978978906542

This is the Code in Sqlite database

public String getMeterNUmber(String MeterNumber) throws SQLException  
{
    String[] whereArgs = new String[]{MeterNumber}; 

Cursor mCursor = db.rawQuery("SELECT MeterNumber FROM " + SCAN_TABLE + " WHERE  Date = ?",whereArgs); 
mCursor.moveToFirst(); 


if(mCursor.getCount() > 0){ 
    MeterNumber = mCursor.getString(0); 
}

return MeterNumber;
} 

this is the code in the class that calls for the query in the sqlite database and take the result to another class by intent

Intent updateCustomerIntent = new Intent(Searching.this, Result.class);
updateCustomerIntent.putExtra("product", dbUser.getMeterNUmber(ss));
 startActivity(updateCustomerIntent);
  • 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-17T16:30:09+00:00Added an answer on June 17, 2026 at 4:30 pm

    First of all, your getMeterNumber method takes a meter number as an argument, as already pointed out in ggenglish’s comment, this seems odd, it should be a date no? Also, your method only calls mCursor.getString(0) once, and then returns that, which means you will only get the meter number from the first row of your result set.

    If you want all the results, you will need to iterate over the full recordset. When you receive the cursor, it will be positioned just before the first row, so, you can loop through it with the method moveToNext(). Then, you will also have to store your result in a appropriate data structs, such as a ArrayList

    ArrayList<String> results = new ArrayList<String>();
    while (mCursor.moveToNext()) {
        results.add(mCursor.getString(0));
    }
    

    So, you will end up with something like this

    public ArrayList<String> getMeterNUmber(String meterDate) throws SQLException  
    {
        String[] whereArgs = new String[]{meterDate}; 
    
        Cursor mCursor = db.rawQuery("SELECT MeterNumber FROM " + SCAN_TABLE + " WHERE  Date = ?",whereArgs); 
    
        ArrayList<String> results = new ArrayList<String>();
        while (mCursor.moveToNext()) {
            results.add(mCursor.getString(0));
        }
    
        mCursor.close();
    
        return results;
    } 
    

    And then finally, use putStringArrayListExtra instead of putExtra when adding the data to the intent.

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

Sidebar

Related Questions

I am trying to build a Python application that connects to Oracle database and
I have an application that I'm trying to build with at least a nominally
I am trying to build an application that retrieves continuous streams of xml data
I am trying to build a class that interacts with the database in my
I'm trying to build an application that will have the following parameters: 1) 2
I'm trying to build application that could help me dial a contact just like
I'm trying to build an application that builds a resource file into a jar,
I'm trying to build a application that has different kinds of users, I'm using
i'm trying to build an application that every given time, will connect to a
I'm trying to build a web application that uses an SSL connection. So I

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.