@Override
  public Uri insert(Uri uri, ContentValues initialValues) {
    String table = getTable(uri);

    ContentValues values;
    if (initialValues != null) {
      values = new ContentValues(initialValues);
    } else {
      values = new ContentValues();
    }

    if ((uri == null) || ((table == null) || (table.length() <= 0))) {
      throw new IllegalArgumentException("Unknow URI " + uri);
    }

    long id = mSQLiteHelper.getWritableDatabase().insert(table, null, values);
    if (id > 0) {
      Log.i(DBHelper.CATEGORY, "New register " + table + " created. Id = " + id);
      Uri notifyUri = ContentUris.withAppendedId(uri, id);
      getContext().getContentResolver().notifyChange(notifyUri, null);
      notifyExtraUris(uri);
      return notifyUri;
    }

    throw new SQLException("Failed to insert row into " + uri);
  }
  /* Usar:
   * Uri uri = Uri.withAppendedPath(CaraterGeralProvider.CONTENT_URI, "getByIndex/"+args.getInt("indice"));
   * */
  @Override
  public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    String table = getTable(uri);

    selection = fillSelection(uri, selection);

    int updatedRows =
        mSQLiteHelper.getWritableDatabase().update(table, values, selection, selectionArgs);

    Log.i(DBHelper.CATEGORY, updatedRows + " rows changed!");

    getContext().getContentResolver().notifyChange(uri, null);
    notifyExtraUris(uri);

    return updatedRows;
  }
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    String table = getTable(uri);

    selection = fillSelection(uri, selection);

    Cursor cursor =
        mSQLiteHelper
            .getWritableDatabase()
            .query(table, projection, selection, selectionArgs, null, null, sortOrder);

    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    return cursor;
  }
  @Override
  public int bulkInsert(Uri uri, ContentValues[] values) {
    String table = getTable(uri);

    int numInserts = 0;
    for (ContentValues contentValues : values) {
      mSQLiteHelper.getWritableDatabase().insert(table, null, contentValues);
    }

    numInserts = values.length;
    Log.i(DBHelper.CATEGORY, numInserts + " new register created.");

    getContext().getContentResolver().notifyChange(uri, null);
    notifyExtraUris(uri);

    return numInserts;
  }
  @Override
  public int delete(Uri uri, String selection, String[] selectionArgs) {
    String table = getTable(uri);

    selection = fillSelection(uri, selection);

    deleteRalationships(uri, selection, selectionArgs);

    try {
      int count = mSQLiteHelper.getWritableDatabase().delete(table, selection, selectionArgs);

      if (count > 0) {
        Log.i(DBHelper.CATEGORY, count + " rows changed!");

        getContext().getContentResolver().notifyChange(uri, null);
        notifyExtraUris(uri);
      }

      return count;
    } catch (Exception e) {
      // TODO: Colocar msg de erro ao deletar
      throw new IllegalArgumentException("Unknow URI " + uri);
    }
  }