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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:39:46+00:00 2026-05-11T22:39:46+00:00

I would like to create a table to store device settings. The table has

  • 0

I would like to create a table to store device settings. The table has three rows: id, parameter_name and parameter_value.

The table was created by executing the following query statement:

DATABASE_CREATE = "create table DATABASE_TABLE (KEY_ID INTEGER PRIMARY KEY AUTOINCREMENT, KEY_NAME INTEGER not null, VALUE TEXT not null);

and then the rows are stored by executing the following method:

private long insertRow(int rowParameter, String rowValue, SQLiteDatabase db){
    long res = -1;
    ContentValues settingsParameterValues = new ContentValues();
    settingsParameterValues.put(KEY_NAME, rowParameter);
    settingsParameterValues.put(VALUE, rowValue);
    if(db != null){
        res = db.insert(DATABASE_TABLE, null, settingsParameterValues);
    }
    return res;
}

When the database is created the default values are stored:

@Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
        insertRow(PRIVACY_LEVEL_ROW_INDEX, "0", db);
        insertRow(STREAM_TITLE_ROW_INDEX, "untitled", db);
        insertRow(STREAM_TAGS_ROW_INDEX, "", db);
    }

The problem with method insertRow() however is that it can’t prevent duplicating the entries.

Does anyone know how to prevent duplicate entries in this case?

  • 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-11T22:39:46+00:00Added an answer on May 11, 2026 at 10:39 pm

    You can use the column constraint UNIQUE.

    The UNIQUE constraint causes an unique index to be created on the specified columns.

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

Sidebar

Related Questions

I would like to create a table that can store, say, the Title or
I would like to create a table that looks/behaves like the one to manage
I would like to create a virtual table with a similar syntax SELECT 'sk:
I would like to create connection between table 1 and table 3 when I
i would like you to help me. I want to create dynamicly table (screenshot).
I would like to know how to create a rounded corners on a table
Rather than create, and then drop a table in sqlite3, I would like to
I have created a MySQL table and would like to save the contents of
I have created a test table in MySQL and would like to insert 10
I would like to create table which can display data from database into JSF

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.