Synchronous API for Android

On backendless document, it says “Most of Backendless API for Android and Java is available in synchronous and asynchronous formats.”, does that mean synchronous API can be used in Android development if I don’t implement heavily on Android GUI?

For my use case, I don’t do GUI, my application needs to complete one Backendless call before moving on to the next call. Can you show me how to implement Synchronous API without getting this exception: “BackendlessException{ code: ‘Internal client exception’, message: ‘null’}”.

Thank you

Do you execute Backendless API calls on the main GUI thread? It does not allow any socket communication and that’s the reason why you experience the error. If you launch a separate thread, you should be able to use sync invocations.


Thank you very much, I will try to launch a separate thread to call the sync api.

It works with new thread.

Thanks again.


I have 2 database tables A and B, if I insert one row to the table A, and 5 rows to the table B in one thread call, it seemed only insert one row for each table. I put a try catch and there were no exception. The for loop executed 5 times. Is there anything that I missed with the sync call. Again, this is inside my new thread, not main GUI thread.

A aRow = new aRow();aRow = Backendless.Persistence.of(A.class).save(aRow);B bRow = new bRow();bRow.setKey() = aRow.getObjectId();for(int i =0; i < 5; i++) {

You save the same object (with same objectId) for 5 times - what do you expect to see in Data console?

That’s not true. I did not set objectId for B rows. The objectId should be generated from B table. However, I do added a custom column to table B to store the value of objectId in table A.

Oh, sorry, I missed the name of setKey() function.

Anyway, you save the same object 5 times. We set the objectId footprint to it under the cover in SDK, for you to be able not to save explicit objectId field.
If you want to save 5 different rows, use Backendless.Persistence.of(B.class).save(new B());

Ah, great. Thank you so much Sergey.

It fixed the problem.