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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:18:36+00:00 2026-05-28T14:18:36+00:00

I have created a database that stores data from the internet.When there is internet

  • 0

I have created a database that stores data from the internet.When there is internet connection,i call createEntry and i write the data into the database. My problem is that the second time that the uses has internet,the new data doesnt overide the old,but the create new entries.So,i think that the solution will be to update my database from the second time that the user has internet connection,so everytime to have the same number of data.My problem is that i dont know how to do it.This is my first try on SQLite and databases.

This is my createEntry:

public void createEntry(String title, String getagonistiki, String getskor,
            String getgipedo, String date, String getgoal1, String getgoal2,
            String teliko_skor) {
        // TODO Auto-generated method stub
        ContentValues cv = new ContentValues();
        cv.put(DBHelper.TITLE, title);
        cv.put(DBHelper.AGONISTIKI, getagonistiki);
        cv.put(DBHelper.SKOR, getskor);
        cv.put(DBHelper.GIPEDO, getgipedo);
        cv.put(DBHelper.DATE, date);
        cv.put(DBHelper.GOALA, getgoal1);
        cv.put(DBHelper.GOALB, getgoal2);
        cv.put(DBHelper.DESCRIPTION, teliko_skor);

        try {
            ourDatabase.insert("osfpDB", null, cv);
        } // ourDatabase.update("osfpDB",cv,DBHelper.ROWID,null);

        catch (Exception e) {
            Log.e("DB ERROR ON .INSERT", e.toString()); // prints the error
                                                        // message to the log
            e.printStackTrace(); // prints the stack trace to the log
        }
    }

and this is what i m calling when there is internet connection:

HotOrNot entry = new HotOrNot(agones.this);

            entry.open();

            entry.createEntry(msg.getTitle(), msg.getagonistiki(), msg
                    .getskor(), msg.getgipedo(), msg.getDate(),msg.getgoal1(),msg.getgoal2(),msg.getDescription());

            // entry.update(msg.getTitle(),msg.getagonistiki(),msg.getskor(),msg.getgipedo(),msg.getDate());

            entry.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-28T14:18:37+00:00Added an answer on May 28, 2026 at 2:18 pm

    Try this function ::

    public void createEntry(String title, String getagonistiki, String getskor, String getgipedo, String date, String getgoal1, String getgoal2,
            String teliko_skor) {
    
        Cursor c = null;
        boolean isInserted = false;
        try {       
            c = ourDatabase.rawQuery("select "+DBHelper.TITLE+" from osfpDB", null);
            if(c != null){
                for(int i=0; i<c.getCount();i++){
                    c.moveToPosition(i);
                    if(c.getString(0).equals(title)){
                        Log.e("same title text means duplicate :",title+" : "+c.getString(0));
                        isInserted = true;
                        break;
                    }
                }
            }
    
            ContentValues cv = new ContentValues();
            cv.put(DBHelper.TITLE, title);
            cv.put(DBHelper.AGONISTIKI, getagonistiki);
            cv.put(DBHelper.SKOR, getskor);
            cv.put(DBHelper.GIPEDO, getgipedo);
            cv.put(DBHelper.DATE, date);
            cv.put(DBHelper.GOALA, getgoal1);
            cv.put(DBHelper.GOALB, getgoal2);
            cv.put(DBHelper.DESCRIPTION, teliko_skor);
    
            Log.e("ourDatabase", "" + ourDatabase);
    
            if (ourDatabase == null) {
                ourDatabase = getWritableDatabase();
            }
    
            if(isInserted){
                ourDatabase.update("osfpDB", cv, null, null);
            }else{
                ourDatabase.insert("osfpDB", null, cv); 
            }
        } catch (Exception e) {
            Log.e("Exception in insert :", e.toString());
            e.printStackTrace();
        }
    }
    

    In your problem i noticed that you want to discard only duplicate records,
    for this you do not need to update record or do not change your code function just set primary key to your table ‘title’ column – this will not allowed to insert duplicate records..(if you have other query tell me)

    ref : Naming conventions

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

Sidebar

Related Questions

I have a normalized database that stores locations of files on the internet. A
I have the session created and it stores the data, that is working 100%;
Say I have a database that stores table data by year using an identical
We have an old Access 2000 database that we need to pull data from
I have a database that I have created using SQL Server Developer 2008. I
I have created a simple windows service that periodically checks a remote database via
I have a batch file that was created for an Oracle database that I'm
I have an Oracle database backup file (.dmp) that was created with expdp .
I have an existing SQL Server database, where I store data from large specific
Let's say I have a database that stores Fruit and FruitBasket s, and it's

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.