Exemple #1
0
  @Override
  public Uri insert(Uri uri, ContentValues values) {
    long regId = 1;

    SQLiteDatabase db = dbh.getWritableDatabase();
    regId = db.insert(TABLA_GASTOS, null, values);

    Uri newUri = ContentUris.withAppendedId(CONTENT_URI, regId);

    return newUri;
  }
Exemple #2
0
  @Override
  public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    int cont;

    // Si es una consulta a un ID concreto construimos el WHERE
    String where = selection;
    if (uriMatcher.match(uri) == GASTOS_ID) {
      where = "_id=" + uri.getLastPathSegment();
    }

    SQLiteDatabase db = dbh.getWritableDatabase();
    cont = db.update(TABLA_GASTOS, values, where, selectionArgs);

    return cont;
  }
Exemple #3
0
  @Override
  public Cursor query(
      Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    // Si es una consulta a un ID concreto construimos el WHERE
    String where = selection;
    if (uriMatcher.match(uri) == GASTOS_ID) {
      where = "_id=" + uri.getLastPathSegment();
    }

    SQLiteDatabase db = dbh.getWritableDatabase();

    Cursor c = db.query(TABLA_GASTOS, projection, where, selectionArgs, null, null, sortOrder);

    return c;
  }