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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:37:33+00:00 2026-06-09T03:37:33+00:00

Just started learning how to program for Android and now I am stuck at

  • 0

Just started learning how to program for Android and now I am stuck at some doubts.

I have one SQLite db with more than one table and each table with some fields.

I’ve created a class to manage my database and imagine that one of the functions is something like this:

public Cursor getGroupData() {
    String[] values = new String[] {_ROWID, _NAME, _AGE, _PHONE};
    Cursor c = db.query(BD_TABLE, values, null, null, null, null, null);
    return c;
}

Now I have one of two situations.

FIRST SITUATION

Want to show, for example, all the names returned on my query in a ListView. With that, the user can click on a name and a new activity will show (imagine a layout with all the user information)

SECOND SITUATION

Want to show, for example, all the names returned on my query in a ListView. With that, the user can click on a name and a new query will be performed (Imagine get other data from that user). The query will result in returning various data and I, again, want to show some field in a ListView (for example the address). Now, if the user clicks on on of the address, a new activity will show up (for example a layout with some information about the address).

In both situation, although I’m just picking a name or an address, all the data returned by the SQLite must be available, for example, on the first situation, I pick a name, it will show on a layout, something like a contact information, but the results from the query, age and phone, must also be available.

For now I’m doing something like:

Cursor values = db.getGroupData();
// Now I'm thinking in putting some code to iterate over the cursor and put what I want to display on my listview on a string array

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values_I_what_to_show);
setListAdapter(adapter);

The problem with this is that I’m putting the data on a string array but will need all the data returned by the query.

Can you point me In some direction?

Regards,

  • 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-09T03:37:35+00:00Added an answer on June 9, 2026 at 3:37 am

    Try this :

     Cursor cursor =db.getGroupData();
     ArrayList<MyData> listData = new ArrayList<MyData>();
     while (cursor.moveToNext()) {
            MyData temp = new MyData();
            temp.id = cursor.getInt(0);
            temp.name = cursor.getString(1);
            temp.age= cursor.getInt(2);
            temp.phone= cursor.getInt(3);
            listData .add(temp);
                        temp =null;
        }
    cursor.close();
    MyAdapter myAdapter = new MyAdapter(this,
                R.layout.list_item, listData); //use custom adapter
    listView.setAdapter(myAdapter);
    

    Declare MyData class :

      private class MyData{
       int id ;
       String name;
       int age;
       int phone;
     }
    

    MyAdapter class :

    private class MyAdapter extends ArrayAdapter<projData> {
        private ArrayList<MyData> items;
        private Context context;
    
        public MyAdapter(Context context, int textViewResourceId,
                ArrayList<MyData> items) {
            super(context, textViewResourceId, items);
            this.context = context;
            this.items = items;
          }
    
        public View getView(final int position, View convertView,
                ViewGroup parent) {
            View view = convertView;
            if (view == null) {
                LayoutInflater inflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.list_item, null);
            }
        //here getview code as per ur req 
            }
        return view;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started android learning recently, and I'm trying to write one program, but
I have started learning Ruby and just tried out my first hello world program
I have just started learning XNA. This is my first program that I am
I have just started learning how to program Windows GUI's using the low level
Very confused over this. I've just started learning about pointers and have now decided
I have recently just started learning how to develop android applications. I am am
I just started learning how to program for android and cant seem to get
I just started learning Android development. I am writing an Android program to scan
Just started learning python (3.2) and have a question. I have created a some
We just started learning windows programming in C++. We have to make a program

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.