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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:01:39+00:00 2026-06-17T04:01:39+00:00

the following code display information from sqlite database on a listview. 1st it shows

  • 0

the following code display information from sqlite database on a listview. 1st it shows Date and the listview allows me to click, when i click on a date it shows me information that was done on that date on a listview. my problem is when i save data on this date 12.01.2013 and i repeat the same date later on then it displays the same date twice and i want it just to display one date and when i click on it to show me the data that i saved in the morning and the data that i saved later on the same day not two similar dates.

hereis the code

public class Pro extends Activity implements OnItemClickListener {

    private ListView uNamesListView;

        private ListAdapter customerListAdapter;
        private ArrayList<PojoClass> pojoArrayList;

    final Context context = this;
    private Button button;
    private TextView result;
    DBAdapter db = new DBAdapter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        uNamesListView = (ListView) findViewById(R.id.listView1);
        uNamesListView.setOnItemClickListener(this);

        pojoArrayList = new ArrayList<PojoClass>();
        customerListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());
        uNamesListView.setAdapter(customerListAdapter);                 


    }

           public List<String> populateList() {


                List<String> uGraduateNamesList = new ArrayList<String>();
                DatabaseHelper openHelperClass = new DatabaseHelper(this);
                SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
                Cursor cursor = sqliteDatabase.query(DBAdapter.SCAN_TABLE, null, null, null, null, null, null);
                startManagingCursor(cursor);
                while (cursor.moveToNext()) {

                    String cDate = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_Date ));
                    String cMeterNumber = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_MeterNumber ));
                    String cVname = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_Vname ));
                    String cPname = cursor.getString(cursor.getColumnIndex(DBAdapter.COLUMN_PName ));

                    PojoClass ss = new PojoClass();
                    ss.SetName(cDate);
                    ss.SetSurname(cMeterNumber);
                    ss.SetID(cVname);
                    ss.SetHaddress(cPname);
                pojoArrayList.add(ss);

                    uGraduateNamesList.add(cDate);
                }
                sqliteDatabase.close();

                return uGraduateNamesList;

    }

    @Override
    public void onItemClick(AdapterView<?> aa, View view, int ss, long bb) {
        // TODO Auto-generated method stub
        Intent updateCustomerIntent = new Intent(Pro.this, ViewByVendor.class);

        updateCustomerIntent.putExtra("product", product);
        startActivity(updateCustomerIntent);

        Toast.makeText(getApplicationContext(), "Clicked on :" + ss, Toast.LENGTH_SHORT).show();
        PojoClass clickedObject =  pojoArrayList.get(ss);

        Bundle dataBundle = new Bundle();

        dataBundle.putString("clickedDate", clickedObject.getDates());
        dataBundle.putString("clickedMeterNumber", clickedObject.getMeterNumber());
        dataBundle.putString("clickedVname", clickedObject.getVname());
        dataBundle.putString("clickedPname", clickedObject.getPname());
        updateCustomerIntent.putExtras(dataBundle);
        startActivity(updateCustomerIntent);


    }


}

i will appreciate your help.

  • 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-17T04:01:40+00:00Added an answer on June 17, 2026 at 4:01 am

    When reading the dates for the list view, you want only unique dates.
    In SQL, this can be done with either DISTINCT or GROUP BY:

    SELECT DISTINCT Date FROM ScanTable
    SELECT Date FROM ScanTable GROUP BY Date
    

    The Android code would look like this:

    cursor = db.query(true,                       // <-- distinct
                      DBAdapter.SCAN_TABLE,
                      new String[] { DBAdapter.COLUMN_Date },
                      null, null, null, null, null, null);
    cursor = db.query(DBAdapter.SCAN_TABLE,
                      new String[] { DBAdapter.COLUMN_Date },
                      null, null,
                      DBAdapter.COLUMN_Date,      // <-- groupBy
                      null, null);
    

    To display the data for the date, you should pass only the date to that activity, and there read all the records that match the date:

    SELECT * FROM ScanTable WHERE Date = ?
    
    String selectedDate = ...;
    cursor = db.query(DBAdapter.SCAN_TABLE, null,
                      DBAdapter.COLUMN_Date + " = ?", selectedDate,
                      null, null, null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following ColdFusion code that is getting information from a database and
I have query that LEFT joins information from two tables. With code with following
Following code is from a sample of playframework-2.0: /** * Display the dashboard. */
I have a Sqlite database that has a table consisting of company information (Companies)
I have the following code that should show the value for the display field
I am using this jquery datatable plugin to display information from database. My table
I have the following code that is used to load user images from a
I use the following c++ code to read out the depth information from the
I have the following code that fails to display object images. But displays normal
The following code should display the id out of the JSON-object, which I got

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.