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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:37:12+00:00 2026-06-04T13:37:12+00:00

I have two other apps that use a ListView and SimpleCursorAdapter . The code

  • 0

I have two other apps that use a ListView and SimpleCursorAdapter. The code is almost the exact same. So I decided to use it again on a third app. It is not working, and cannot find a solution.

The problem is that there is nothing displayed in the list. I use a button to add information into the database. I was logging a count on the cursor Log.d("",storyCur.count()+""); to make sure the database was being updated and it is.

Relevant Database Code:

public Cursor fetchAll(){
  return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID,KEY_DETAILS,KEY_TITLE},
  null, null, null, null, null);
}

Rest of relevant code:

ListView lv;
DbAdapter db;

public void onCreate(Bundle savedInstanceState) {
...
   lv = (ListView) findViewById(R.id.list);
   db = new DbAdapter(this);
....
}

public void onResume(){
    super.onResume();
    db.open();
    fillData();
}

private void fillData(){
    Cursor storyCur = db.fetchAll();
    startManagingCursor(storyCur);

    String[] from = new String[]{DbAdapter.KEY_LOC};
    int[] to = new int[]{R.id.row1};

   SimpleCursorAdapter stories = 
      newSimpleCursorAdapter(this,R.layout.story_row,storyCur,from,to);

   lv.setAdapter(stories);

    storyCur.close();
}

main XML:

  <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:onClick="onClick" />

  <ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
  </ListView>

</LinearLayout>

story_row XML:

<?xml version="1.0" encoding="utf-8"?>



<TextView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/row1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:padding="10dp"
  android:background="#444444" />
  • 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-04T13:37:14+00:00Added an answer on June 4, 2026 at 1:37 pm

    You should remove the call to .close() on the cursor. SimpleCursorAdapter needs the cursor to be open in order to function and will call close() on the cursor for you.

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

Sidebar

Related Questions

I have two apps that use custom URL schemes to switch between each other.
I have two fields that need to multiply each other and fill a third
I have two apps that use Integrated Security. One assigns Integrated Security = true
I have two .NET applications that talk to each other over a named pipe.
I have two classes that refer to each other, but obviously the compiler complains.
We want to have two .NET apps running on the same machine communicate with
I have two programs written in C++ that use Winsock. They both accept TCP
I have two applications which use the same content provider, but I can't put
I have a SQL table that will be accessed by two console apps (.NET).
I have two completely independent web application that each use a shared core dll.

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.