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

  • Home
  • SEARCH
  • 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 7551991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:38:39+00:00 2026-05-30T10:38:39+00:00

What I am trying to accomplish here is to make a Cursor that could

  • 0

What I am trying to accomplish here is to make a Cursor that could be used in an android ListView. I’m reading values directly from multiple files and have to feed them to the cursor. I tried to use MatrixCursor but I can’t get it to work with arrays. I have posted my attempt at it so far below and I’m open to all new suggestions. Is there a simpler way to do this?

static MatrixCursor getnameList() {
        ArrayList<String> fsitem = getfsiList();
        MatrixCursor cursor;
        cursor = null;
        for (int i = 0; i < fsitem.size(); i++) {
            try {
                File root = new File(Environment.getExternalStorageDirectory()
                        .getName() + "/" + fsitem.get(i));
                if (root.canRead()) {
                    File namefile = new File(root, ".name");
                    FileReader namereader = new FileReader(namefile);
                    BufferedReader in = new BufferedReader(namereader);
                    String name = in.readLine();
                    String id = in.readLine();
                    String info = in.readLine();
                    String[] fsii = new String[3];
                    fsii[0]= name;
                    fsii[1]= id;
                    fsii[2]= info;
                    cursor.addRow(fsii); //crashes here on running.
                }

            } catch (IOException e) {
                Log.e("NameManager.java : ", ("Error!! Not Writable!!"
                        + Environment.getExternalStorageDirectory().getName()
                        + "/" + fsitem.get(i)));
            }
        }

This code compiles but crashes at cursor.addRow(fsii);:

with 02-24 21:16:49.589: E/AndroidRuntime(3895): at com.manager.abcd.r1223.NameManager.getnameList(NameManager.java:81).

I’m thinking this is a problem with MartixCursor not supporting arrays, but I might be wrong. Any ideas?

  • 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-30T10:38:40+00:00Added an answer on May 30, 2026 at 10:38 am

    If this is all the code then it is normal because you try to add a row on a null cursor(you never initialize cursor) and probably get a NullPointerException.
    Initialize the MatrixCursor before you enter in the for loop:

    String[] columnNames = {"col1", "col2", "col3"};
    MatrixCursor cursor = new MatrixCursor(columnNames);
    

    Check the docs.

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

Sidebar

Related Questions

I'm trying to accomplish what is described here: http://sqldev.wordpress.com/2008/05/06/insert-into-temporary-table-from-stored-procedure/ The article says (with support
Here is what I am trying to accomplish. I have a form that uses
Here's what I'm trying to accomplish with this program: a recursive method that checks
What I'm trying to do here is make one function that does all the
What I am trying to accomplish here is to separate a firstname, lastname combo
I'm trying to accomplish what should be a very simple task using the ListView
Here is my lehmans terms of what i am trying to accomplish. i will
here is what im trying to accomplish here. I want a image to start
I'm building a simple aggregator-type app that would pull in data from multiple websites
Here's what I'm trying to accomplish. I need to have a single CSV with

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.