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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:21:46+00:00 2026-05-20T09:21:46+00:00

My code : ListContacts .java public class ListContacts extends ListActivity { @Override public void

  • 0

My code :
ListContacts .java

public class ListContacts extends ListActivity {

  @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /** Associate the xml with the activity */
    setContentView(R.layout.home);

              Cursor cursor = getContentResolver().query(
            ContactsContract.Contacts.CONTENT_URI, null,
            ContactsContract.Contacts.HAS_PHONE_NUMBER + " = 1", null,
            "UPPER(" + ContactsContract.Contacts.DISPLAY_NAME + ") ASC");

    startManagingCursor(cursor);

    /** start mapping */
    String[] columns = new String[] { ContactsContract.Contacts.DISPLAY_NAME };
    int[] names = new int[] { R.id.contact_name };
    lAdapter = new ImageCursorAdapter(this, R.layout.contact_listview,
            cursor, columns, names);

    setListAdapter(lAdapter);
}

ImageCursorAdapter .java

 public class ImageCursorAdapter extends SimpleCursorAdapter {

 public View getView(int pos, View inView, ViewGroup parent) {

//System.out.println("  ImageCursorAdapter : getView : ");
View v = inView;
String phoneNumber = null;
String contactID = null;

// Associate the xml file for each row with the view
if (v == null) {
    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = inflater.inflate(R.layout.main, null);
}
this.c.moveToPosition(pos);

/**
 * Get the strings with the name and number of the person that the
 * current row
 */

//
String lName = this.c.getString(this.c
    .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
//System.out.println("  ImageCursorAdapter : getView : lName " + lName);

/**
 * Get the person's id and from the id retrieve the contact's picture
 */

int contactId = c.getColumnIndex(ContactsContract.Contacts._ID);
/*System.out.println("  ImageCursorAdapter : getView : contactId "
    + contactId);*/

long contact_id = this.c.getLong(this.c
    .getColumnIndex(ContactsContract.Contacts._ID));

Cursor cr = context.getContentResolver().query(Phone.CONTENT_URI,
    new String[] { Phone.NUMBER, Phone.CONTACT_ID },
    Phone.CONTACT_ID + "=" + contact_id, null,
    Phone.IS_SUPER_PRIMARY + " DESC");

if (cr.moveToFirst()) {
   // System.out.println(" Phone number : " + cr.getString(0));
    phoneNumber = cr.getString(0);

    contactID = cr.getString(1);
    //System.out.println("contactID " + contactID);
}

}

A null pointer exception is thrown on the line if(cr.moveToFirst()) of ImageCursorAdapter.java while scrolling the listview 9-10 times. And the exception is given below:

03-01 16:04:23.007: ERROR/IMemory(9227): cannot dup fd=1023, size=1048576, err=0 (Too many open files)
03-01 16:04:23.007: ERROR/IMemory(9227): cannot map BpMemoryHeap (binder=0x3e5af0), size=1048576, fd=-1 (Bad file number)
03-01 16:04:23.007: ERROR/JavaBinder(9227): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
03-01 16:04:23.007: ERROR/JavaBinder(9227): java.lang.RuntimeException: No memory in memObj
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.database.CursorWindow.native_init(Native Method)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.database.CursorWindow.<init>(CursorWindow.java:518)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.database.CursorWindow.<init>(CursorWindow.java:27)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:493)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:496)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:108)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at android.os.Binder.execTransact(Binder.java:288)
03-01 16:04:23.007: ERROR/JavaBinder(9227):     at dalvik.system.NativeStart.run(Native Method)


03-01 16:04:23.017: ERROR/AndroidRuntime(9560): java.lang.NullPointerException
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at com.test.ImageCursorAdapter.getView(ImageCursorAdapter.java:143)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.AbsListView.obtainView(AbsListView.java:1294)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.ListView.makeAndAddView(ListView.java:1727)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.ListView.fillUp(ListView.java:682)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.ListView.fillGap          (ListView.java:628)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2485)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.os.Handler.handleCallback(Handler.java:587)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.os.Looper.loop(Looper.java:144)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at android.app.ActivityThread.main(ActivityThread.java:4937)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at java.lang.reflect.Method.invokeNative(Native Method)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at java.lang.reflect.Method.invoke(Method.java:521)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-01 16:04:23.017: ERROR/AndroidRuntime(9560):     at dalvik.system.NativeStart.main(Native Method)

Please 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-05-20T09:21:47+00:00Added an answer on May 20, 2026 at 9:21 am

    Make sure that you close the cr cursor every time in the adapter

    Cursor cr = ...
    try {
        // use cr
    } finally {
        cr.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code-behind: public partial class WebForm1 : System.Web.UI.Page { protected override void OnInit(EventArgs e) {
code: public class Main{ public static void main(String[] a){ long t=24*1000*3600; System.out.println(t*25); System.out.println(24*1000*3600*25); }
Code from the book Java Concurrency in Practice Listing 8.1 Why is the code
Code # get already active Excel application or open new my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
Code below doesn't work on any browser. It's supposed to show an alert box.
Code: $('#Inputfield').keyup(function(e) { if(e.which == 13) { functionXyz(); } else { functionZyx(); } });
Code: $(.box-collapse).live(click,function(){ if(updating()) return false; var b = $(this).parent().parent(); b.find(.album-div).stop(true,false).slideToggle(); $.ajax({ url: addNonce($(this).attr(href)), success:function(data){
I have a layout having the contact deatils of the phone. When i click
Basically, I have stored information in a database field and I want to display
The following function compares a new list of items to an old one and

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.