У меня есть ListActivity, чтобы показать Arraylist.В onListItemClick () я вызываю другой ListActivity.У меня есть определенный класс, который расширяет SQLiteOpenHelper () для управления БД.
В первом ListActivity у меня есть этот код
protected void onListItemClick(ListView l, View v, int position, long id) {
String selection = l.getItemAtPosition(position).toString();
secondListActivity itemsList= new secondListActivity();
itemsList.showItemsList(selection);
//Toast.makeText(this, selection, Toast.LENGTH_LONG).show();
}
Метод showComicsList () в secondListActivity имеет
public void showItemsList(String name)
{
DatabasesManager databaseHelper = new DatabasesManager(this);
Cursor series = databaseHelper.getItemsIdByName(name);
Cursor cursor = databaseHelper.getChildren(series.getString(0));
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
//fetching from database and adding to arrayList
results.add(cursor.getString(cursor.getColumnIndex(ChildrensTable.NUMBER)));
}
cursor.close();
//display in screen
this.setListAdapter(
new ArrayAdapter<Object>(
secondListActivity.this,
android.R.layout.simple_list_item_1,
results
)
);
}
getItemsIdByName () вызывает курсор
public Cursor getItemsIdByName(String name)
{
return( getReadableDatabase().query(
itemsTable.TABLE_NAME,
null,
"name =" + name,
null,
null,
null,
null,
null));
}
Когда я вызываю getItemsIdByName (), я получаю эту ошибку
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): FATAL EXCEPTION: main
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): java.lang.NullPointerException
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:118)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at zepod.whatelsecomics.databases.wecDatabasesManager.getComics(wecDatabasesManager.java:159)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at zepod.whatelsecomics.WhatelsecomicsListActivity.showComicsList(WhatelsecomicsListActivity.java:25)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at zepod.whatelsecomics.WhatelsecomicsActivity.onListItemClick(WhatelsecomicsActivity.java:47)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.widget.ListView.performItemClick(ListView.java:3513)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1800)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.os.Handler.handleCallback(Handler.java:587)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.os.Looper.loop(Looper.java:123)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at android.app.ActivityThread.main(ActivityThread.java:3647)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at java.lang.reflect.Method.invokeNative(Native Method)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at java.lang.reflect.Method.invoke(Method.java:507)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-12 14:12:17.906: ERROR/AndroidRuntime(6090): at dalvik.system.NativeStart.main(Native Method)
Может ли кто-нибудь мне помочь?