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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:16:13+00:00 2026-06-16T00:16:13+00:00

this is the error… 12-17 17:17:30.729: E/SQLiteDatabase(21112): Error inserting nome=categoriaTest 12-17 17:17:30.729: E/SQLiteDatabase(21112): android.database.sqlite.SQLiteConstraintException:

  • 0

this is the error…

12-17 17:17:30.729: E/SQLiteDatabase(21112): Error inserting nome=categoriaTest
12-17 17:17:30.729: E/SQLiteDatabase(21112): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.database.sqlite.SQLiteStatement.native_executeInsert(Native Method)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:113)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1844)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1717)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at com.ggservice.democracy.pollDataSource.createCategoria(pollDataSource.java:40)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at com.ggservice.democracy.MainActivity.onClick(MainActivity.java:44)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at java.lang.reflect.Method.invokeNative(Native Method)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at java.lang.reflect.Method.invoke(Method.java:511)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.view.View$1.onClick(View.java:3064)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.view.View.performClick(View.java:3591)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.view.View$PerformClick.run(View.java:14263)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.os.Handler.handleCallback(Handler.java:605)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.os.Handler.dispatchMessage(Handler.java:92)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.os.Looper.loop(Looper.java:137)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at android.app.ActivityThread.main(ActivityThread.java:4507)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at java.lang.reflect.Method.invokeNative(Native Method)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at java.lang.reflect.Method.invoke(Method.java:511)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-17 17:17:30.729: E/SQLiteDatabase(21112):    at dalvik.system.NativeStart.main(Native Method)

while, the button that should do this is like:

public void onClick(View view) {
        @SuppressWarnings("unchecked")
        ArrayAdapter<categorie> adapter = (ArrayAdapter<categorie>) getListAdapter();
        categorie categoria = null;
        switch (view.getId()) {
        case R.id.add:

          // Save the new comment to the database
          categoria = datasource.createCategoria("categoriaTest");
          adapter.add(categoria);
          break;

        }
        adapter.notifyDataSetChanged();
      }

and the createCategoria is like:

public categorie createCategoria(String categoria) {
            ContentValues values = new ContentValues();
            values.put(MySQLiteHelper.COLUMN_NOME, categoria);
            long insertId = database.insert(MySQLiteHelper.TABLE_CATEGORIE, null,
                values);
            Cursor cursor = database.query(MySQLiteHelper.TABLE_CATEGORIE,
                allCategorieColumns, MySQLiteHelper.COLUMN_ID + " = " + insertId, null,
                null, null, null);
            cursor.moveToFirst();
            categorie newCategoria = cursorToCategorie(cursor);
            cursor.close();
            return newCategoria;
          } 

the SQliteHelper:

public class MySQLiteHelper extends SQLiteOpenHelper {

      public static final String TABLE_CATEGORIE = "categorie";
      public static final String TABLE_SONDAGGI = "sondaggi";
      public static final String TABLE_TESTORISPOSTE = "testo_risposte";
      public static final String TABLE_RISPOSTE = "risposte";    
      public static final String COLUMN_ID = "_id";
      public static final String COLUMN_NOME = "nome";
      public static final String COLUMN_PREF = "preferita"; 
      public static final String COLUMN_CATID = "catid";
      public static final String COLUMN_DOMANDA = "domanda";
      public static final String COLUMN_SONDID = "sondid";
      public static final String COLUMN_RISPOSTA = "risposta";
      public static final String COLUMN_RISID = "risid";
      public static final String COLUMN_SELEZIONATA = "selezionata";


      private static final String DATABASE_NAME = "democracy.db";
      private static final int DATABASE_VERSION = 2;

      // Database creation sql statement


      private static final String DATABASE_CREATE_CATEGORIE = "create table "
          + TABLE_CATEGORIE + "(" + COLUMN_ID
          + " integer primary key autoincrement, " + COLUMN_PREF
          + " integer not null, " + COLUMN_NOME
          + " text not null);";

      private static final String DATABASE_CREATE_SONDAGGI = "create table "
              + TABLE_SONDAGGI + "(" + COLUMN_ID
              + " integer primary key autoincrement, " + COLUMN_CATID
              + " integer not null, "+ COLUMN_DOMANDA +" text not null);";


      private static final String DATABASE_CREATE_TESTORISPOSTE = "create table "
              + TABLE_TESTORISPOSTE + "(" + COLUMN_ID
              + " integer primary key autoincrement, " + COLUMN_SONDID
              + " integer not null, "+ COLUMN_SELEZIONATA
              + " integer not null, "+ COLUMN_RISPOSTA +" text not null);";


      public MySQLiteHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
      }

      @Override
      public void onCreate(SQLiteDatabase database) {
        database.execSQL(DATABASE_CREATE_CATEGORIE);
        database.execSQL(DATABASE_CREATE_SONDAGGI);
        database.execSQL(DATABASE_CREATE_TESTORISPOSTE);


      }

      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(MySQLiteHelper.class.getName(),
            "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_CATEGORIE);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_SONDAGGI);
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_TESTORISPOSTE);



        onCreate(db);
      }

    } 

i don’t know if you need some more, i’m a quite a noob at android, but i’m trying to understand, i’m actually trying to “transform” a tutorial in a real application, by adding more tables, making a good DAO and so on…
have you got any advice?
P.S. is there a way to “look at” the database i “probably” create in the device?

  • 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-16T00:16:14+00:00Added an answer on June 16, 2026 at 12:16 am

    The problem is that your Column COLUMN_PREF cannot be null, and you’re inserting a null in your method by not inserting anything:

    COLUMN_PREF + " integer not null,"
    

    –

    ContentValues values = new ContentValues();
    values.put(MySQLiteHelper.COLUMN_NOME, categoria);
    long insertId = database.insert(MySQLiteHelper.TABLE_CATEGORIE, null, values);
    

    Just add that value to the insert or remove the ‘not null’ clause.

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

Sidebar

Related Questions

This code gives me this error:Cannot implicitly convert type ArrayList[] to ArrayList[][] at this
This code give me this error: c.apply is not a function All code works
So this error is killing me, heres the code: $html = file_get_html('vids.html'); foreach($html->find('a') as
This code giving error in IE Internet Explorer Cannot Open the Internet Site Operation
This error does not happen anywhere else. I can even open a version database
Getting this error while compiling C++ code: undefined reference to `__stack_chk_fail' Options already tried:
This code produces an error in the GNU compiler: class A { public: int
This error was shown when I build a android application program in Eclipse: 14:43:33
This error is inexplicably occurring. Here is the code and output: timer.cpp: #include timer.h
This error is just bizarre, my code compiles fine, I can see there are

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.