当游标返回行超过200时,应用程序崩溃
这是代码
private void Search() {
EditText EditText_search = (EditText) findViewById(R.id.searchText);
searchText = EditText_search.getText().toString();
if(searchText!="")
{
fetch.clear();
mDbHelper = new rewaya.books.shiaa.database.DatabaseAdapter(
getApplication());
try {
mDbHelper.createDataBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cursor cursor = mDbHelper.selectQuery(GenerateSQLCommand(searchText));
int count = cursor.getCount();
if (count > 0) { this.startManagingCursor(cursor);
String[] columns = new String[] { "_id", "SectionName", "Text" };
int[] to = new int[] { R.id.ID, R.id.SectionName, R.id.Text };
final SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.item_search_result, cursor, columns, to);
ListView chapterListView = (ListView) findViewById(R.id.searchlist);
cursor.moveToFirst();
ArraySearchResult = new ArrayList<RowStructure>();
for (int i = 0; i < count; i++) {
fetch.add(new RowStructure(cursor.getInt((cursor
.getColumnIndex("_id"))), formatText(cursor
.getString(cursor.getColumnIndex("SectionName"))),
formatText(cursor.getString(cursor
.getColumnIndex("Text")))));
RowStructure ShourtCutRow = new RowStructure(cursor.getInt(0),
cursor.getString(1), cursor.getString(2));
ArraySearchResult.add(ShourtCutRow);
cursor.moveToNext();}
}
Collections.reverse(ArraySearchResult);
adapter = new CustomArrayAdapter(SearchActivity.this,
R.id.searchResultListview, fetch);
lv.setAdapter(adapter);
final Bundle bundle = new Bundle();
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
startParagraphPagerActivity(position);
}
});
mDbHelper.close();
this.stopManagingCursor(cursor);
}
else
{
Toast.makeText(getApplicationContext(), "لم يتم العثور على نتائج بحث", Toast.LENGTH_LONG).show();
}
}
else
Toast.makeText(getApplicationContext(), "يرجى ادخال كلمة البحث", Toast.LENGTH_LONG).show();
}
04-22 15:55:23.520:D / AndroidRuntime(8829):关闭VM 04-22 15:55:23.520:W / dalvikvm(8829):threadid = 1:线程退出时未捕获异常(group = 0x40bdb1f8) 04-22 15:55:23.527:E / AndroidRuntime(8829):致命异常:主要 04-22 15:55:23.527:E / AndroidRuntime(8829):java.lang.IllegalStateException:database /data/data/rewaya.books.shiaa/databases/fekr.db(conn#0)已经关闭 04-22 15:55:23.527:E / AndroidRuntime(8829):在android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2214)