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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:28:39+00:00 2026-05-29T20:28:39+00:00

Working on my first Android app and facing a challenge. I am pulling calls

  • 0

Working on my first Android app and facing a challenge.
I am pulling calls from CallLog contentprovider and displaying using a cursor adapter.
I have overriden bindView and newView. I am not using SimpleCursorAdapter as I need to format the date. I am new to Android so prone to silly mistakes. 🙂
I am calling this cursorAdapter in the main Activity using this code.

startManagingCursor(calls);
adapter = new CallsAdapter(this, calls);
setListAdapter(adapter);

public void bindView(View view, Context context, Cursor cursor) {
    displayDate(view, date);
}

private void displayDate(View view, String strDate) {
    final long timestamp = Long.parseLong(strDate);
    final String formattedDate = DATEFORMAT.format(new Date(timestamp));
    final TextView t = (TextView) view.findViewById(R.id.date_text);
    t.setText(formattedDate);
}

public View newView(Context context, Cursor cursor, ViewGroup parent) {
    final View view = LayoutInflater.from(context).inflate(R.layout.scratch_layout2, parent, false);
    return view;
}

But my app crashes before it starts.

Edited – Heres the error log.

ERROR/AndroidRuntime(12885): Uncaught handler: thread main exiting due to uncaught exception
02-09 06:05:28.281: ERROR/AndroidRuntime(12885): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amannain.android.missedcalls/com.amannain.android.missedcalls.MissedCallsActivity}: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 6
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.os.Looper.loop(Looper.java:123)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread.main(ActivityThread.java:3948)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at java.lang.reflect.Method.invokeNative(Native Method)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at java.lang.reflect.Method.invoke(Method.java:521)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at dalvik.system.NativeStart.main(Native Method)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 6
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.database.AbstractCursor.checkPosition(AbstractCursor.java:580)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:172)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:41)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.database.CursorWrapper.getString(CursorWrapper.java:135)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at com.amannain.android.missedcalls.MissedCallsAdapter.<init>(MissedCallsAdapter.java:24)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at com.amannain.android.missedcalls.MissedCallsActivity.onCreate(MissedCallsActivity.java:27)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
02-09 06:05:28.281: ERROR/AndroidRuntime(12885):     ... 11 more

Regards,
Aman

  • 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-29T20:28:40+00:00Added an answer on May 29, 2026 at 8:28 pm

    In your MissedCallsAdapter you seem to call the cursor in the constructor long before the adapter is really initialized

    Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 6
    at android.database.CursorWrapper.getString(CursorWrapper.java:135) 
    at com.amannain.android.missedcalls.MissedCallsAdapter.<init>(MissedCallsAdapter.java:24)
    at com.amannain.android.missedcalls.MissedCallsActivity.onCreate(MissedCallsActivity.java:27)
    

    Check line 24 of your adapter code. Or rather line 27 where this call to the constructor happens in onCreate.

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

Sidebar

Related Questions

I'm working for the first time with Forms Authentication, I'm using an example from
I'm working on my first Android app, and am almost to the point where
I'm very new to java and am working on my first Android app. I
I'm working on an android app where I have only 2 activities... The first
I'm working on my first android app and have an SQLite database set up
I'm working on my first Android app and to be honest I'm not sure
I'm working on creating a checkbook app for android using a database to record
I am currently working on my first android app. In a listview, I need
Working on my first Android app here. I've searched and tried everything I can
I'm curently working on my first Android app, which is my first pice of

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.