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

The Archive Base Latest Questions

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

So my situation is this. I have two tables, e.g. employee and department. When

  • 0

So my situation is this. I have two tables, e.g. employee and department. When a new employee is made, there is a spinner which is populated from the departments database, when this is selected it inserts it in to a field in the employee table.

What I am trying to do is have a list of departments and once the department is clicked, it shows all employee’s that belong to that department.

So heres what I have so far, the first code is from my class which displays the department list:

    protected void onListItemClick(ListView l, View v, int position, long empDept) {
        super.onListItemClick(l, v, position, empDept);
        Intent i = new Intent(this, EmployeeActivity.class);
        i.putExtra(DatabaseAdapter.DEPT_NAME, empDept);
        startActivityForResult(i, ACTIVITY_START); 
    }

I am passing this to the employee list activity, I have tested the code by just displaying everything so it is working to some extent but when I am trying to view by the selected dept name it returns nothing, here is the section of the class that receives the intent:

private void fillData() {

        Bundle extras = getIntent().getExtras(); 
        long result = extras.getLong("empDept");

        Cursor empCursor= DbHelper.getEmpByDept(result);

        startManagingCursor(empCursor);

And here is my database query:

 public Cursor getEmpByDept(long empDept)
 {
     return mDb.query(EMP_TABLE, new String[] { EMP_ID, EMP_TITLE,
                EMP_NOTES, EMP_DATE_TIME, EMP_DEPT }, EMP_DEPT + "=" + empDept, null,
                null, null, null, null);
 }

So what I’m trying to do is just show the employees when the department clicked matches what is in the employees EMP_DEPT field.

Any help is greatly appreciated.

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

    in extras.getLong() the input is the key of the bundle, that is DatabaseAdapter.DEPT_NAME and not "empDept". Also make sure that DatabaseAdapter.DEPT_NAME, the key, includes a proper package prefix as indicated in the doc.

    btw.: you don’t need the last null in the query which is optional and refers to LIMIT (if you don’t have one)

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

Sidebar

Related Questions

this is my situation: I have two org.w3c.dom.Document created from two xml files. What
Just after some advice regarding this database design situation. So I have two tables
So my situation is this. I have two tables. A main table where data
This is the situation: I have two tables where the one references the other
In this situation I have two models, Comment and Score. The relationship is defined
This is my situation. I have two activities: ONE and TWO. In TWO activity
I have a one-to-many relationship between two classes for this situation. I have a
In a situation where I have two tables: Games(id, player1Id, player2Id) Players(id, gender) And
Here is the situation, i have two tables tblProduct and tblCategory, what i am
if our situation is the standard view where you have two tables and a

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.