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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:53:13+00:00 2026-05-27T18:53:13+00:00

In my application, I use SQLiteOpenHelper class and it has insertOrThrow method. I want

  • 0

In my application, I use SQLiteOpenHelper class and it has insertOrThrow method. I want to learn that will this method close my connection before throw an exception? And it is written on definition of method that “the row ID of the newly inserted row, or -1 if an error occurred ”

When throw an exception how it has a return value? Something is wrong. Explanation or throw ?

This is how I use InsertOrThrow.
I want to know when I declare throws Exception to my method, is it necessary to use try-catch (If I don’t have any special thing to do in catch like my exp.)?

public long insert(ContentValues cv) throws Exception {
    try
    {
        long rowId = getWritableDatabase().insertOrThrow(_tableName, null, cv);
        return rowId;
    }
    catch (Exception ex) {
        throw ex;
    }
    finally{
        Close();
    }
}
  • 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-27T18:53:14+00:00Added an answer on May 27, 2026 at 6:53 pm

    It depends; if this.Close() can throw an exception, then it still needs to be declared as being thrown, or caught. Often times this is wrapped up in a small utility method.

    It’s not mandatory to use a catch, you can simply try/finally.

    Regarding return values: methods that exit due to an exception don’t have a return value.

    Exceptions should encapsulate enough information to either:

    • allow the caller to do something useful with the exception, e.g., retry the operation, or
    • assist the developer in understanding the problem and lead him/her to a resolution.

    I’d encourage you to follow standard Java naming conventions to avoid confusing readers of your code: non-final variables should begin with a lower-case letter. Method names should also begin with lower-case letters.

    Also, you do not need to preface methods (or variables) with this when there is no need to disambiguate the property you’re accessing.

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

Sidebar

Related Questions

My application use white color font which is okay on my phone that has
I have web application - use Spring + Tomcat. I need debug method that
Somebody said that when your PHP code and application use global variables then it
my application use 10 threads that to read a lot of html file.similar the
Hello I've just implemented a search option on my application use this on the
I have a large application that uses EJB 2.x entity beans (BMP). This is
My Android application includes an SQLite database with an SQLiteOpenHelper class to help manage
i currently build an application use spring as framework. and i want to test
Application use NHibernate. I Have object A that contains set of objects B. I
I have an large ASP.Net web application that will have a large number of

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.