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 7747493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:32:37+00:00 2026-06-01T10:32:37+00:00

i am using a Android database and it’s set up; but when i call

  • 0

i am using a Android database and it’s set up; but when i call it within an onClickListener the app crashes.

the code i am using is

db.open();
mButton.setOnClickListener(
        new View.OnClickListener()
        {
            public void onClick(View view)
            {
               s = WorkoutChoice.this.weight.getText().toString();
               s2 = WorkoutChoice.this.height.getText().toString();
               int w = Integer.parseInt(s);
               double h = Double.parseDouble(s2);
               double BMI = (w/h)/h;
               t.setText(""+BMI);
               long id = db.insertTitle("001", ""+days, ""+BMI);
               Cursor c = db.getAllTitles();
               if (c.moveToFirst())
               {
                   do {          
                       DisplayTitle(c);
                   } while (c.moveToNext());
               }
            }
        });
        db.close();

and the log cat for when i run it is:

 04-01 18:21:54.704: E/global(6333): Deprecated Thread methods are not supported.
04-01 18:21:54.704: E/global(6333): java.lang.UnsupportedOperationException
04-01 18:21:54.704: E/global(6333):     at java.lang.VMThread.stop(VMThread.java:85)
04-01 18:21:54.704: E/global(6333):     at java.lang.Thread.stop(Thread.java:1391)
04-01 18:21:54.704: E/global(6333):     at java.lang.Thread.stop(Thread.java:1356)
04-01 18:21:54.704: E/global(6333):     at com.b00348312.workout.Splashscreen$1.run(Splashscreen.java:42)
04-01 18:22:09.444: D/dalvikvm(6333): GC_FOR_MALLOC freed 4221 objects / 252640 bytes in 31ms
04-01 18:22:09.474: I/dalvikvm(6333): Total arena pages for JIT: 11
04-01 18:22:09.574: D/dalvikvm(6333): GC_FOR_MALLOC freed 1304 objects / 302920 bytes in 29ms
04-01 18:22:09.744: D/dalvikvm(6333): GC_FOR_MALLOC freed 2480 objects / 290848 bytes in 33ms
04-01 18:22:10.034: D/dalvikvm(6333): GC_FOR_MALLOC freed 6334 objects / 374152 bytes in 36ms
04-01 18:22:14.344: D/AndroidRuntime(6333): Shutting down VM
04-01 18:22:14.344: W/dalvikvm(6333): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
04-01 18:22:14.364: E/AndroidRuntime(6333): FATAL EXCEPTION: main
04-01 18:22:14.364: E/AndroidRuntime(6333): java.lang.IllegalStateException: database not open
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1567)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1484)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at com.b00348312.workout.DataBaseHelper.insertTitle(DataBaseHelper.java:84)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at com.b00348312.workout.WorkoutChoice$3.onClick(WorkoutChoice.java:84)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.view.View.performClick(View.java:2408)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.view.View$PerformClick.run(View.java:8817)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.os.Handler.handleCallback(Handler.java:587)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.os.Looper.loop(Looper.java:144)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at android.app.ActivityThread.main(ActivityThread.java:4937)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at java.lang.reflect.Method.invokeNative(Native Method)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at java.lang.reflect.Method.invoke(Method.java:521)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-01 18:22:14.364: E/AndroidRuntime(6333):     at dalvik.system.NativeStart.main(Native Method)

I have noticed errors when the application opens but i don’t know where they are from.

When I take out the statements to do with the database there are no errors and everthing runs smoothly.

  • 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-06-01T10:32:39+00:00Added an answer on June 1, 2026 at 10:32 am

    It won’t help if the database is only open while you set the listener, it has to be open when you use it. Call open() and close() INSIDE the onCLick().

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

Sidebar

Related Questions

In PhoneGap how do I create/open a database in Android? I am using this
I'm working on creating a checkbook app for android using a database to record
I've got an android app using a local sqlite database. private SQLiteDatabase mDb; when
I've implemented access to a database using SQLiteOpenHelper from the android.database package within some
I am currently using PHPmyadmin to store data in my mySQL database. The android
I'm using Android's SQLite to create a database of levels, based on some files.
I'm having trouble querying my SQLite database using Android. I keep getting either an
I was developing android app on eclipse till now and now I'm using Mono
I am making an android database app in which when i fetch values from
I'm making Android app that has this database in it: public void onCreate(SQLiteDatabase db)

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.