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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:34:10+00:00 2026-06-13T18:34:10+00:00

This is a very weird problem. I’ll just post the code directly: package com.asim.contactspull;

  • 0

This is a very weird problem. I’ll just post the code directly:

package com.asim.contactspull;

    public class Contact
    {
    private String name;
    private String number;

    public Contact(String sname, String snumber)
    {
        this.name = sname;
        this.number = snumber;
    }
    }

The above is my custom class. Following is my MainActivity:

package com.asim.contactspull;

public class MainActivity extends Activity
{
    ArrayList<Contact> contactList;
    ListView contacts;

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

        contactList = new ArrayList<Contact>();

        Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null,null, null);
        while (phones.moveToNext())
        {
            Contact c = new Contact(phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)), phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
            Log.d("Contact: ", "" + c.toString());
            contactList.add(c);
        }
        phones.close();

        contacts = (ListView) findViewById(R.id.contacts);
        ArrayAdapter<Contact> aa = new ArrayAdapter<Contact>(this, android.R.layout.simple_list_item_1, contactList);
        contacts.setAdapter(aa);
    }
}

When I run the above code, I get entries like this in my ListView:

com.asim.contactspull
Contact@405206e8

What am I doing wrong?

  • 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-13T18:34:12+00:00Added an answer on June 13, 2026 at 6:34 pm

    you need to override toString() method to get a proper representation of your class.

    like this:

    public String toString(){
       return this.name;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very weird problem. My app that runs just fine but somehow
This is a very weird problem am facing HTML: <input type=button id=buttonobj class=some class
I have a very weird problem that I can't understand. This is C code:
This is very weird. I have the following code: Assert.AreEqual(new DateTime(2000, 1, 1), DateTime.ParseExact(2000,
I have a very weird problem using OpenMP in my C++ code: void update(double
I got this very weird problem...and it's very important to my...dead line is close...and
ohk i am facing this very weird problem . i have a cloud server
I have a very weird problem. This ONLY affects Firefox on Mac, using the
Today, i have very weird problem with trim function. Here is my code. =and
This is a very weird problem. I think I must be doing something wrong,

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.