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
.