Update does not update

0

The app works like this: An SMS is received, so the app checks if the number that sent this SMS is registered, if the app checks the first twenty characters of the message, which I call text (example: Light 1 .. .............- ON, or: Light 1 ...............- DSL). If this text exists then the app updates the message in the database, otherwise it inserts a new message. The problem is the time to do Update, not the error in the execution, however it does not update. below the update:

public Long atualiza (ReceiveOne receiveOne) {

    db = this.getWritableDatabase();

    ContentValues valores = new ContentValues();

    valores.put(RECEIVE_ONE_DATA, receiveOne.getReceiveOne());

    return (long) db.update(RECEIVE_ONE_NAME, valores, RECEIVE_ONE_KEY + " =?", new String[]{String.valueOf(receiveOne.getId())});

}

and below is the code that calls the method:

receiveOne.setReceiveOne(smsBody.toString());

receiveOne.setId(db.questTextReceiverOne(smsBody));

db.atualiza(receiveOne);

The smsBody is the received SMS. the questTextReceiverOne() method checks the existence of the text and returns the id.

I tested several update methods and it's still the same.

id = 0. //retorno do atualiza = 0

db = SQLiteDatabase: /data/data/com.example.usuario.infinium8/databases/SMS.

In the database I have only one message. The existing message is: led 1 ...............- ON the SMS arrives: led 1 ...............- DSL, as the led text 1 - is the same as the one in the database the message goes to the update.

The update method is in SQLiteOpenHelper and is called in BroadcastReceiver .

    
asked by anonymous 30.09.2015 / 19:53

1 answer

1

The answer was to create a method in which I enter the received sms, it checks the text and returns the object from the database:

public ReceiveOne quest_IdReceiverOne (String message) {

    int size = receiveOneSize();

    List<ReceiveOne> list = selectReceiverOne();

    ReceiveOne receiveOne = new ReceiveOne();

    for (int i = 0; i < size; i++) {

        String data = String.valueOf(list.get(i));

        if (data.substring(0, 19).equals(message.substring(0, 19)))
            return receiveOne = list.get(i);
    }

    return null;

}
    
02.10.2015 / 21:19