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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:59:07+00:00 2026-06-18T09:59:07+00:00

In my application, I tried using the following codes to validate the user email

  • 0

In my application, I tried using the following codes to validate the user email address exists in database or not. If the user email address does not exist it will insert the user info into database. But this message appeared and I cant get the user info into the database. I not really sure what the issue here.

MainActivity.java

public void onCreate(){
   helper = new DBHelper(this);


    Button loginButton = (Button) findViewById(R.id.login_btn);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view)
        {
            if(useremail.length() == 0){

                alertMessage = "Please enter Email Address.";
                dialogBox();
            }
            else if (password.length() == 0){

                alertMessage = "Please enter Password.";
                dialogBox();
            }

            else {
                emailid = useremail.getText().toString();
                userpassword = password.getText().toString();

               if(!helper.emailidChecking(emailid)){
                    helper.insert_wbm_user(emailid);
               }
               else{
                    alertMessage="User email exists";
                    dialogBox();
               }
           }
        }
     });
}





public void onDestroy(){
       super.onDestroy();
       helper.close();
}

DBHelper.java

    public boolean emailidChecking(String emailid) throws SQLException
{
    helper = this.getReadableDatabase();
    Log.i(TAG, "emailidChecking:" +emailid);
    Cursor c = helper.rawQuery("SELECT * from user_info where emailid='"+emailid+"'", null);
    if(c.getCount()==0){  
        //not in db
        Log.i(TAG, "getCount = 0");
        return true;
    }
    if (c != null && !c.isClosed()) {
        c.close();
    }
    if (helper!=null){
        helper.close();
    }

    return false;

}


public long insert_user_info(String emailid) {

    ContentValues cv=new ContentValues();
    cv=new ContentValues();
    cv.put("emailid", emailid);

    Log.i(TAG, "insert db");

    long createdinMsg = getWritableDatabase().insert("user_info", "emailid", cv);
    return createdinMsg;

}

Logcat

01-29 10:03:12.007: D/Cursor(2143): Database path: /data/data/com.ff.fbin/databases/wbdb.db
01-29 10:03:12.007: D/Cursor(2143): Table name   : null
01-29 10:03:12.007: D/Cursor(2143): SQL          : SQLiteQuery: SELECT * from user_info where emailid='asd@hotmail.com'
01-29 10:03:12.007: I/dalvikvm(2143): Uncaught exception thrown by finalizer (will be discarded):
01-29 10:03:12.007: I/dalvikvm(2143): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@405b07e8 on null that has not been deactivated or closed
01-29 10:03:12.011: I/dalvikvm(2143):   at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:620)
01-29 10:03:12.011: I/dalvikvm(2143):   at dalvik.system.NativeStart.run(Native Method)
  • 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-18T09:59:08+00:00Added an answer on June 18, 2026 at 9:59 am
    public boolean emailidChecking(String emailid) throws SQLException
     {
    helper = this.getReadableDatabase();
    Log.i(TAG, "emailidChecking:" +emailid);
    Cursor c = helper.rawQuery("SELECT * from user_info where emailid='"+emailid+"'", null);
    try
    {
        if(c.getCount()==0){  
            //not in db
           Log.i(TAG, "getCount = 0");
           c.close();   <-------- Close the cursor here.
           return true;
         }
     }
     finally
     {
         c.close();
         if (helper!=null){
            helper.close();
           }
       }
     } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried using the following Perl code, but the worksheet does not copy
I'm using the following code, which works, to login a user to an application
The following code does not get me the correct file: <?php header(Content-Type: application/octet-stream); readfile(http://player.vimeo.com/play_redirect?clip_id=24195442&sig=49daac0ff885745c27601a80402bba14&time=1351783454&quality=hd&codecs=H264&type=moogaloop_local&embed_location=);
I tried using both ReadProcessMemory() and WriteProcessMemory() in my application,but in both cases I
Has Anyone tried using PDF in iPad Application, using CGPDf functions. I have used
has anybody tried using a custom classloader with BlazeDS? We have a web application
I'm looking to build a tree-like structure for my Java application. I've tried using
I tried to create a new Swing GUI desktop application template using NetBean 7.0
Has anyone tried to back up a SharePoint web application using forms based authentication
I'm using tesseract in my iPhone application. I tried several filters on my image

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.