我正在尝试访问数据库“listOfFolder”表“文件夹”中的所有数据,并希望将数据存储在字符串数组文件夹 [] 中,但我正在了解如何解决 ArrayIndexOutOfBoundsException。
try{
mydb = openOrCreateDatabase("listOfFolder", MODE_WORLD_WRITEABLE, null);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
int count = 0;
String folders[] = null;
Cursor folderCursor = mydb.query("folder", null, null, null, null, null, null);
while(folderCursor.moveToNext()) {
folders[count] = folderCursor.getString(folderCursor.getColumnIndex("name"));
count++;
}
ListView list = (ListView)findViewById(R.id.lv);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(DropboxActivity.this, android.R.layout.simple_list_item_1,folders);
list.setAdapter(adapter);
setContentView(R.layout.listoffolder);