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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:23:04+00:00 2026-06-08T01:23:04+00:00

Hey this is my onCreate method for a SQLiteDatabase that is of course called

  • 0

Hey this is my onCreate method for a SQLiteDatabase that is of course called when a new database is created. I want to catch any problem and log and then rethrow it for handling up above. However the compiler is not allowing me to rethrow the exception, complaining that it is not handled. This is on the line that reads “throw e;”.

@Override
public void onCreate(SQLiteDatabase db) {//arg0?
    db.beginTransaction();
    try {
        Checklist.createTable(db);
        Item.createTable(db);
        db.setTransactionSuccessful();
    } catch (Exception e) {
        Log.e(KnowUrStuffApp.TAG,"KusDBHelper.onCreate: " + e.getLocalizedMessage());           
        db.endTransaction();
        throw e;//SYNTAX ERROR: Unhandled Exception Type Exception
    }
}
  • 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-08T01:23:05+00:00Added an answer on June 8, 2026 at 1:23 am

    Your problem is, that you’re throwing a checked exception. This can only be done when this exception is

    1. directly caught and handled by a try/catch-block
    2. or the exception is thrown “upwards” by adding throws SomeException to your method-signature.

    However, in your case, you’re overriding the onCreate()-method, which (in the base-class) does not throw a checked exception. Therefore, you can’t override the method and add throws to the signature, because that wouldn’t be an override anymore.

    What you can do is, throw a RuntimeException upwards, which doesn’t need to be added to the method signature:

    Log.e(KnowUrStuffApp.TAG,"KusDBHelper.onCreate: " + e.getLocalizedMessage());           
    db.endTransaction();
    throw new RuntimeException(e); // Add the checked exception as the cause!
    

    For more information on Exceptions (throwing and catching), see my blog-post: Catching practice

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

Sidebar

Related Questions

Hey this is the weirdest problem i've ever encoutered, I have 2 projects that's
Hey I want to create a layout like this for my application. Of course
hey this is how I must have made ​​such that if the database can
hey guys having this really simple problem but cant seem to figure out have
hey there i have this code that should save a file from sql server
hey there guys and girls i have this code that saves json as a
Hey this may be a somewhat simple question, but I'm new to Eclipse and
hey this is so that I should just have put some infomation into the
Hey this is my problem, i can not align tis input field with these
Hey all I've created Google's exmaple of a tab layout HelloTabWidget.java: public void onCreate(Bundle

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.