Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6571133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:50:35+00:00 2026-05-25T14:50:35+00:00

i have a ListActivity to show an Arraylist. In the onListItemClick() i call another

  • 0

i have a ListActivity to show an Arraylist.
In the onListItemClick() i call another ListActivity.
I have a specific class to extends SQLiteOpenHelper() to manage db.

In the first ListActivity i have this code

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();
}

The showComicsList() method in the secondListActivity have

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
    )
  );
}

the getItemsIdByName() call a cursor

public Cursor getItemsIdByName(String name)
{
  return( getReadableDatabase().query(
  itemsTable.TABLE_NAME, 
  null, 
  "name =" + name,
  null, 
  null,
  null, 
  null, 
  null));
}

When i call the getItemsIdByName() i get this error

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)

Can someone help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:50:36+00:00Added an answer on May 25, 2026 at 2:50 pm

    It’s likely the context on your secondListActivity is not set since you are just instantiating it normally without using startActivity

    This is the line that I assume where you are instantiating your second list (where your context is null):

     secondListActivity itemsList= new secondListActivity();
    

    If you follow this stacktrace:

    android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)

    In the Android source code, you will see that line 203 is

      return mBase.openOrCreateDatabase(name, mode, factory);
    

    Where mBase is the context that you set in SQLiteOpenHelper.

    In your code, assuming DatabasesManager is the one who will interact with SQLiteOpenHelper, it is likely this that you pass to it is null

    
    // "this" is possibly null
    DatabasesManager databaseHelper = new DatabasesManager(this);
    Cursor series = databaseHelper.getItemsIdByName(name);
    

    If you want to use second list in the same Activity, you should consider using the ListView directly in the code without wrapping it using the another ListActivity

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a activity that extends listactivity, extended in this class i have a
I have a class defined as public class viewGroups extends ListActivity Somewhere in the
I have: One MyListActivity class extends ListActivity setContentView(R.layout.mylist) ; Two xml files: mylist.xml and
I have a listactivity which contains a listview. i want to show another layout
i have created a My custom listActivty by extending ListActivity like this. public class
I have the first activity that call a dialog from second activity with this
public class List_Items extends ListActivity{ private ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); public
I have this code in my DataBase Helper: public ArrayList<ArrayList<Object>> getAllRowsAsArrays() { // create
I have Activity for displaying search results. It extends ListActivity. I need to show
I have an activity: public class Notepadv1 extends ListActivity { public static final int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.