title: Insert or update in SQlite and Android using the database.query();
body: <p>is there a way to change my function:</p>
  
  <pre><code>public categorie createCategoria(String categoria) {
              ContentValues values = new ContentValues();
              values.put(MySQLiteHelper.COLUMN_NOME, categoria);
              values.put(MySQLiteHelper.COLUMN_PREF, 0);
  
              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;
            } 
  </code></pre>
  
  <p>this is a raw insert, i would like to change this function to make it update or insert accordingly. i would like to change this becouse i'm already using this function in some places, but now i need to choose if insert a row or update (or ignoring the insert) a row with the same <code>COLUMN_NOME</code>. can someone help me doing this?</p>
  
  <p>i mean i would like to insert a new row ONLY if there isn't another with the same name (as usual you know).</p>