Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set current timestamp for every insert and update row in realm android

Tags:

android

realm

I want to synchronize the android application with server. In Server i have maintained last update date through trigger as it uses SQL server but my android application uses Realm so how can i set current date time in a field whenever any row is inserted or updated. Any suggestion would be highly appreciated.

like image 268
Syed Hassan Avatar asked Sep 23 '15 09:09

Syed Hassan


1 Answers

use this

    realm.beginTransaction();
    RealmResults<ModelClass> hallos =     realm.where(ModelClass.class).equalTo('name', 'hello').findAll();
    for (ModelClass object : hallos) {
        object.setTimeStamp(timestamp);
    }
    realm.commitTransaction();
like image 84
Ashish Agrawal Avatar answered Nov 10 '22 23:11

Ashish Agrawal