how to save data that returns a cursor Android
<pre><code>private static final String DATABASE_CREATE =
    "create table tasks (_id integer primary key autoincrement, "

    + "title text not null,"
    +"location text not null, " 
    + "body text not null , "
    +" goaldate text not null , "
    +" absolutedate text not null , "
    +"currentdate text not null , "
    +"prio text not null, "
    +"done text not null, "
    +"category text not null, "
    +"timespent text not null, "
    +"pososto text not null,"
    +"father text not null);";

// fetch all tasks(tasks and subtasks)
public Cursor fetchTasks() { 

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER},null, null, null, null, null);

}

//fetch subtasks of a task, given the father's key
public Cursor fetchSubTasks(String id) { 

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER}, KEY_FATHER + " LIKE" + "'"+ id+"'", null, null, null, null);

}

//fetch a subtask
public Cursor fetchSubTask(String fid,String uid) { // tropopoihsh ths methodou wste sthn arxiki othoni na fainontai mono oi tasks

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER}, KEY_FATHER + " LIKE" + " '"+ fid +" '"+ " AND " + KEY_ROWID + " LIKE " + " '"+ uid +"' ", null, null, null, null);

}

          mCursor= mDbHelper.fetchTasks();//fetching all the tasks
          int numberoftasks= mCursor.getCount();
          this.mCursor.moveToFirst();
          int n,m;
          String id, idf;

          int columnIndex= 0;
          for(n=0;n&lt;=numberoftasks;n++){

              id=this.mCursor.getString(0);//unique id of the current task

              mCursor=mDbHelper.fetchSubTasks(id);// fetching the subtasks with father_id=id

              String[] my = new String[mCursor.getCount()];

                if (mCursor.moveToFirst())
                {                       
                    for (int i = 0; i &lt; mCursor.getCount(); i++)
                    {
                        my[i] = mCursor.getString(columnIndex);
                        mCursor.moveToNext();
                    }           
                }

            m=0;


            int subtasks=mCursor.getCount();

            int j;
            for(j=0;j&lt;=subtasks;j++){

                  mCursor=mDbHelper.fetchSubTask(id, my[j]);// fetching each time the task with the unique id( from the array)
                                                             //and father_id=id

                  LinearLayout list = (LinearLayout)v.findViewById(R.id.linear); // fill a textview of the list with one more textview
                  list.removeAllViews();
                  LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

               //   for (Music music : albums.get(position).musics) {
                      View line = inflater.inflate(R.layout.tasks_row, null);

                      /* nested list's stuff */

                      list.addView(line);
                  }

                m++;
          }

             this.mCursor.moveToNext(); 
         // }
</code></pre>

<p>I have a database with a table tha is filled with tasks. every task has a unique id and a father's id in order to achieve nesting. my problem is that i cannot save properly the data that the cursor returns and i get an arrayOutOfboundsException.
here is my code. thank you in advance</p>

<hr>

<pre><code>     private static final String DATABASE_CREATE =
    "create table tasks (_id integer primary key autoincrement, "

    + "title text not null,"
    +"location text not null, " 
    + "body text not null , "
    +" goaldate text not null , "
    +" absolutedate text not null , "
    +"currentdate text not null , "
    +"prio text not null, "
    +"done text not null, "
    +"category text not null, "
    +"timespent text not null, "
    +"pososto text not null,"
    +"father text not null);";

  // fetch all tasks(tasks and subtasks)
public Cursor fetchTasks() { 

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER},null, null, null, null, null);

}

//fetch subtasks of a task, given the father's key
public Cursor fetchSubTasks(String id) { 

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER}, KEY_FATHER + " LIKE" + "'"+ id+"'", null, null, null, null);

}

//fetch a subtask
public Cursor fetchSubTask(String fid,String uid) { // tropopoihsh ths methodou wste sthn arxiki othoni na fainontai mono oi tasks

    return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE,
            KEY_BODY,KEY_location  , KEY_GOAL_DATE,KEY_ABSOLUTE_DATE, KEY_DATE_CURRENT ,KEY_PRIO,KEY_DONE, KEY_CATEGORY,KEY_TIME_SPEND,KEY_POSOSTO, KEY_FATHER}, KEY_FATHER + " LIKE" + " '"+ fid +" '"+ " AND " + KEY_ROWID + " LIKE " + " '"+ uid +"' ", null, null, null, null);

}
</code></pre>

<p>here is my code @Sam. Main tasks appear on a list and the thing that i want to do is to fetch the subtasks of each task(multiple levels, each subtask can have subtasks) and show them in a kind of list.(create a particular textview with details for each task every time that a task has a subtask).thank you in advance for any help or idea.</p>
