Hi I am facing some problem while reading from Backendless table?

Hi I am trying to read a contact table through following code-

    String whereClause = "userEmail = 'test@test3.com'";
    DataQueryBuilder queryBuilder = DataQueryBuilder.create();
    queryBuilder.setWhereClause(whereClause);
    //queryBuilder.setGroupBy("name");



    Backendless.Persistence.of(Contact.class).find(queryBuilder, new AsyncCallback<List<Contact>>() {
        @Override
        public void handleResponse(List<Contact> response) {
            ApplicationClass.contacts = response;
            adapter = new ContactsAdapter(ContactList.this,ApplicationClass.contacts);
            lvList.setAdapter(adapter);
     
        }

        @Override
        public void handleFault(BackendlessFault fault) {
            Toast.makeText(ContactList.this,fault.getMessage(),Toast.LENGTH_SHORT).show();
            showProgress(false);

        }
    });

But when I am running this.I am not getting the records instead I see the following logs in debugger-
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@c5ee153[MainActivity]
W/RenderThread: type=1400 audit(0.0:136450): avc: denied { read } for name=“u:object_r:vendor_default_prop:s0” dev=“tmpfs” ino=15928 scontext=u:r:untrusted_app:s0:c224,c256,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
E/libc: Access denied finding property “vendor.debug.egl.changepixelformat”
W/RenderThread: type=1400 audit(0.0:136451): avc: denied { read } for name=“u:object_r:vendor_default_prop:s0” dev=“tmpfs” ino=15928 scontext=u:r:untrusted_app:s0:c224,c256,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0
E/libc: Access denied finding property “vendor.debug.egl.swapinterval”
Disconnected from the target VM, address: ‘localhost:8602’, transport: ‘socket’

What may be the issue and how to resolve?

Hi, i think you used android emulator, YES? if yes, may be problem is in using emulator not with backendless, but answer this questions:

did you get handleResponse or handleFault in CallBack?

if you got handleFault, please share fault message if not, share me response value.

Hi Morteza,

I am getting handleResponse but no record is retrieved.
https://drive.google.com/file/d/1bGXxyvggtx-rEXktx-s4kyqvP88EVu3B/view?usp=sharing

Regards,
Subhadip

Hi Subhadip Dutta

See https://backendless.com/docs/android/data_search_with_where_clause.html -> Find all contacts by name.
You use find through Backendless.Persistence.
Try find using Backendless.Data.
Try and let know what happened.

Regards, Vladimir

Hi Vladmir,

As you can see in code attached I am doing the same thing.Even attached database table screenshot showing records are there for the criteria.Any pointers will be helpfull.

Thanks & Regards,
Subhadip

Hi, please test Vladimir Yalovy response: check Backendless.Data instead of Backendless.Persistence. let me know what happened.

Hello,

It is not clear from the screenshot what the result is: whether you get any error inside handleResponse or just the response list is empty. If latter, please check if you have any permissions denied in Users -> Security Roles tab. If permissions are OK, please let us know your application ID so that we could try to issue the same request and reproduce the issue.

Hi @morteza-hosseini/@Volodymyr_Ialovyi,

I did what you asked and i am getting the response but need your assistance since i need to put it in my contact class to set to custom adapter to show in list.As well why is the persistence not working?

https://drive.google.com/open?id=1bGXxyvggtx-rEXktx-s4kyqvP88EVu3B

Thanks & Regards,
Subhadip

Hi @sergey-chupov,

It seems persistence is not working.I checked with Data.of and that is working but still facing issue in setting it to custom adapter through custom class.Attached doc.

https://drive.google.com/open?id=1bGXxyvggtx-rEXktx-s4kyqvP88EVu3B

Regards,
Subhadip

Unfortunately, I’m no Android expert to assist you with setting the data to the adapter, and this is actually out of our support forum’s scope. But I believe there are lots of great articles on how to do that (official Android docs, for example) and there are people eager to help on StackOverflow.

Hi @sergey-chupov,

I had copy pasted the persistence code from one of the android forums.Can you atleast confirm that the persistence code which I was using is wrong way.

Thanks & Regards,
Subhadip

In the google docs document you have referenced, it is inconclusive to me what the screenshots showing values in the debugger reference. If you get a response object back in the handleResponse handler, it means Backendless delivered the data to your application and the persistence API did its job. If you’re struggling to figure out how to bind that data to a UI component, try search for an answer online, Stackoverflow or Android forums as that question is entirely for the client-side (while Backendless is a server-side technology)

Hi @mark-piller,

As you can see in the doc i have used Data.of(tablename) instead of the persistence.of(Contact.class).My question is -Is the persistence mechanism wrong?

Thanks & Regards,
Subhadip

Both Backendless.Data and Backendless.Persistence point to the same object in the code and it makes absolutely no difference which one you use:

hI @mark-piller,

If that is the case then why is the class through which i created the entity not retrieving the data and i have to explicitly mention table name.Please see the attached doc.

Regards,
Subhadip

It is not clear from your doc that the data is not retrieved. What would be helpful is if you set a breakpoint where it is shown below and then show in the debugger what the value of the response variable:

Additionally, it would be helpful to see what the Contact class looks like.

Regards,
Mark

1 Like

Hi @mark-piller,

The response is retrieved in the list.Thanks for all your support.

Regards,
Subhadip