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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:26:37+00:00 2026-06-14T05:26:37+00:00

I have a save button that should basically create a new entry in my

  • 0

I have a save button that should basically create a new entry in my SQLite database IF there isn’t already one with the same ‘name and number'(both are stored as strings).
If there is already an entry with the same name and number, it should make a popup asking if they want to overwrite.

What actually happens is it creates a new entry whether or not the entry already exists.
Code that runs when you click save:

final String thename=TeamName.getText().toString()
final String thenum=TeamNum.getText().toString();
if ((thename.length()!=0) && (thenum.length()!=0)){
    ScoutingFormData info1 = new ScoutingFormData(this);
    info1.open();
    final long returnedId=info1.scanFor(thename,thenum);
    if (returnedId==-1){
        info1.createEntry(thename,thenum);
    }
    else
    {
        final Dialog overw=new Dialog(this);
        ....//The code that goes here is unimportant to my question so I'm hiding it.
        overw.show();
    }
    info1.close();  
}

Code in ScoutingFormData.java:

public long scanFor(String thename, String thenum) {
    String[] columns=new String[]{KEY_ROWID,KEY_NAME,KEY_NUM};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
    int iID = c.getColumnIndex(KEY_ROWID);
    int iName = c.getColumnIndex(KEY_NAME);
    int iNum = c.getColumnIndex(KEY_NUM);
    for (c.moveToFirst(); !c.isAfterLast();c.moveToNext()){
        if ((c.getString(iName)==thename) && (c.getString(iNum)==thenum)){
            return Long.parseLong(c.getString(iID));
        }
    }
    return -1;
}

I don’t see how it could possibly return -1 if an entry already exists with the same name+number.

  • 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-14T05:26:38+00:00Added an answer on June 14, 2026 at 5:26 am

    Use equals to compare String values.

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

Sidebar

Related Questions

I have some data that multiple Activities need to manipulate. Basically there is one
I currently have a simple form that when you click the save button will
I have a database that stores an arbitrary number of phone numbers. There are
I have a page that should contain two ace:fileEntry tags: one to upload an
I have a save button in a JFrame ;on clicking save the 'save' text
I have an application without a save button; saving happens automatically in the background.
I have a actionSave class which extends AbstractAction.I use it for save button. somewhere
I have a foreach for editing some items. Each item has a Save button.
I have two buttons for my form - a Save changes button and a
In my application I have a button to save some information. However, I would

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.