Pandy
Pandy

Reputation: 145

i cant create string array with cursor data in android

private static final String Memo_Name = "MemoName"; 

.

openDB();
            String[] col = new String[] {Memo_Name};
            Cursor c = db.query(Memo_Table, col, null, null, null, null, null);
            String[] result = new String[c.getCount()-1];
                 if(c.moveToFirst()){
                      for (int i = 0; i < c.getCount(); i++){
                          result[i] = c.getString(c.getColumnIndex(Memo_Name));
                          c.moveToNext();
                        }//end of for
                 }
                db.close();

ArrayIndexOutOfBoundsException on this line

result[i] = c.getString(c.getColumnIndex(Memo_Name));

Upvotes: 0

Views: 718

Answers (1)

Joe
Joe

Reputation: 2243

glad I could help. just so you could close the question -

remove the " -1 "

Upvotes: 2

Related Questions