delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

insert to collection issues #92

Closed daniel6435 closed 8 years ago

daniel6435 commented 8 years ago

Hi,

I like to know when insert data failure, where to get the exception ? or is there possible to know the data insert to collection is successful ?

Thanks

prasannakumark commented 8 years ago

Hi,

you can use this insert method to identifying the what exact problem and all.

mMeteor.insert(DATABASE_NAME, insertValues, new ResultListener() {
            @Override
            public void onSuccess(String result) {
                Toast.makeText(getActivity(),"Record has been sucessfully inserted ",Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onError(String error, String reason, String details) {
                Toast.makeText(getActivity(),"error "+error,Toast.LENGTH_SHORT).show();
            }
     });
ocram commented 8 years ago

@prasannakumark Thank you very much for your help!

@daniel6435 The proposed solution is the correct one :) Just add a ResultListener to your insert call as shown and use the onError method to get informed about errors.