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

  • SEARCH
  • Home
  • 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 5966963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:52:28+00:00 2026-05-22T19:52:28+00:00

THis is myDB Class //Please take a look at public Cursor getplaces() — Am

  • 0

THis is myDB Class
//Please take a look at public Cursor getplaces() — Am i right or wrong?
and How to code in main Activity class if i want to setListAdapter. Thank you for your help.

public class MyDB { 
    protected static final String TAG = "TAG";

    private final Context mContext;
    private SQLiteDatabase mDb;
    private MyDBhelper mDbHelper;
public MyDB(Context context){   
    this.mContext = context;
    mDbHelper = new MyDBhelper(mContext);
}

public MyDB createDatabase() throws SQLException 
{
    try 
    {
        mDbHelper.createDataBase();
    } 
    catch (IOException mIOException) 
    {
        Log.e(TAG, mIOException.toString() + "  UnableToCreateDatabase");
        throw new Error("UnableToCreateDatabase");
    }
    return this;
}

public MyDB open() throws SQLException 
{
    try 
    {
        mDbHelper.openDataBase();
        mDbHelper.close();
        mDb = mDbHelper.getReadableDatabase();
    } 
    catch (SQLException mSQLException) 
    {
        Log.e(TAG, mSQLException.toString());
        throw mSQLException;
    }
    return this;
}


    public Cursor getplaces() 
    {
        Cursor c = mDb.query(Constants.DATABASE_NAME, null, null, null, null, null, null);
        return c;

    }

    public void close() 
    {
        mDbHelper.close();
    }

}

ListplaceActivity Class

public ListplaceActivity extends ListActivity {



    private static MyDB mDbHelper;
    String[] from = new String[] { Constants.TITLE_NAME };
    int[] to = new int[] {R.id.place_title};


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        mDbHelper = new MyDB(this);
        Cursor c = mDbHelper.getplaces();
        setListAdapter(new SimpleCursorAdapter(this, 
                  R.layout.list_place, c, 
                  from, to));

        final ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View view,int position, long id) {

                Intent newActivity = new Intent(view.getContext(), Place.class);     
                startActivity(newActivity);

            }
          });
    }

}

in LogCat show like this after i click to go to ListplacesActivity page it occur “Stopped Unexpectedly” and didn’t show any list :

05-30 21:49:21.543: INFO/Process(17605): Sending signal. PID: 17605 SIG: 9
05-30 21:49:21.583: INFO/ActivityManager(59): Process com.ctg (pid 17605) has died.
05-30 21:49:21.593: INFO/WindowManager(59): WIN DEATH: Window{44de90a0 com.ctg/com.ctg.CTG paused=false}
05-30 21:49:21.674: INFO/ActivityManager(59): Start proc com.ctg for activity com.ctg/.CTG: pid=27207 uid=10028 gids={}
05-30 21:49:21.733: ERROR/gralloc(59): [unregister] handle 0x5fe9d8 still locked (state=40000001)
05-30 21:49:22.103: DEBUG/ddm-heap(27207): Got feature list request
05-30 21:49:22.265: INFO/UsageStats(59): Unexpected resume of com.ctg while already resumed in com.ctg
05-30 21:49:23.084: DEBUG/dalvikvm(27207): GC freed 801 objects / 58520 bytes in 216ms
05-30 21:49:23.433: DEBUG/dalvikvm(27207): GC freed 93 objects / 3632 bytes in 129ms
05-30 21:49:23.623: WARN/PhoneWindow(27207): Previously focused view reported id 16908298 during save, but can't be found during restore.
05-30 21:49:23.843: WARN/InputManagerService(59): Got RemoteException sending setActive(false) notification to pid 17605 uid 10028
05-30 21:49:24.103: INFO/ActivityManager(59): Displayed activity com.ctg/.CTG: 2489 ms (total 33589 ms)
05-30 21:49:29.013: INFO/ActivityManager(59): Starting activity: Intent { cmp=com.ctg/.AttractionsListActivity }
05-30 21:49:29.085: DEBUG/AndroidRuntime(27207): Shutting down VM
05-30 21:49:29.085: WARN/dalvikvm(27207): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-30 21:49:29.094: ERROR/AndroidRuntime(27207): Uncaught handler: thread main exiting due to uncaught exception
05-30 21:49:29.114: ERROR/AndroidRuntime(27207): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ctg/com.ctg.AttractionsListActivity}: java.lang.NullPointerException
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.os.Looper.loop(Looper.java:123)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread.main(ActivityThread.java:4363)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at java.lang.reflect.Method.invokeNative(Native Method)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at java.lang.reflect.Method.invoke(Method.java:521)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at dalvik.system.NativeStart.main(Native Method)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207): Caused by: java.lang.NullPointerException
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at com.ctg.data.MyDB.getplaces(MyDB.java:82)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at com.ctg.AttractionsListActivity.onCreate(AttractionsListActivity.java:32)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-30 21:49:29.114: ERROR/AndroidRuntime(27207):     ... 11 more
05-30 21:49:29.144: INFO/Process(59): Sending signal. PID: 27207 SIG: 3
05-30 21:49:29.144: INFO/dalvikvm(27207): threadid=7: reacting to signal 3
05-30 21:49:29.174: INFO/dalvikvm(27207): Wrote stack trace to '/data/anr/traces.txt'
05-30 21:49:39.039: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
05-30 21:49:39.057: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{44eae320 com.ctg/.AttractionsListActivity}
  • 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-22T19:52:29+00:00Added an answer on May 22, 2026 at 7:52 pm

    You didn’t call MDbHelper.open(), so the variable mDb inside getPlaces() is null.

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

Sidebar

Related Questions

I have this method in my db class public function query($queryString) { if (!$this->_connected)
This is for my DB class. I am new to OO, been a procedural
I use lazy connection to connect to my DB within my DB object. This
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small
This is a difficult and open-ended question I know, but I thought I'd throw
This is my first post here and I wanted to get some input from

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.