Basic Search

Based on the documentation for basic search, I’m trying to retrieve data but the returned BackendlessCollection<> is null. Here’s my code:

public class VideoInfo {


    private String mName;
    private String mVideoThumbnailUri;
    private String mTitle;
    private String mVideoUri;
    private String mObjectId;


    public String getName() {
        return mName;
    }


    public void setName(String name) {
        mName = name;
    }


    public String getObjectId() {
        return mObjectId;
    }


    public void setObjectId(String objectId) {
        mObjectId = objectId;
    }


    public VideoInfo(){}




    public String getTitle() {
        return mTitle;
    }


    public void setTitle(String title) {
        mTitle = title;
    }




    public String getVideoUri() {
        return mVideoUri;
    }


    public void setVideoUri(String videoUri) {
        mVideoUri = videoUri;
    }


    public String getVideoThumbnailUri() {
        return mVideoThumbnailUri;
    }


    public void setVideoThumbnailUri(String videoThumbnailUri) {
        mVideoThumbnailUri = videoThumbnailUri;
    }
}


Backendless.initApp(this,
        app_code,
        secrect_key,
        "v1");


Backendless.Persistence.of(VideoInfo.class).find(new AsyncCallback&lt;BackendlessCollection&lt;VideoInfo&gt;>() {
    @Override
    public void handleResponse(BackendlessCollection&lt;VideoInfo&gt; videoInfoBackendlessCollection) {
        for (VideoInfo info : videoInfoBackendlessCollection.getData()) {
            Log.v(TAG, "data: " + info.getTitle());
            Log.v(TAG, data: " + info.getVideoThumbnailUri());
        }
    }


    @Override
    public void handleFault(BackendlessFault backendlessFault) {
        Log.v(TAG, "error_details: " + backendlessFault.getDetail());
        Log.v(TAG, "error_msg: " + backendlessFault.getMessage());
    }
});

Hi Hedayat,

What is the name of the table where you load the data from? Based on the code it should be named “VideoInfo”. Could you please post a screenshot of the table schema from Backendless console?

Also, do you work with your own installation of Backendless? In this case, you need to change the endpoint URL in the library. Have you done that?

Regards,
Mark

Yes, It’s VideoInfo.

No, the data is on Backendless Cloud server.
For the case of localhost, you mean the following code, right?

Backendless.setUrl("my_localhost");

http://s6.uplod.ir/i/00718/cnyredvmhd2u.png
</img>

Is this how you have it in the code?:

Backendless.setUrl("my_localhost");

Also, I cannot see the image you attached. Could you try again?

http://support.backendless.com/public/attachments/8e99c981452b5ac2e81ef63dd82d387a.png&lt;/img&gt;

It doesn’t matter if I’m using localhost or your cloud server, still facing the problem.

The returned BackendlessCollection’s size is 5 since I have 5 columns in my database but the data itself is null.

Columns in your database do not define the size of BackendlessCollection. A column is mapped to a property/field in your object. You have 5 records in the screenshot. Can you tell me exactly what value is null? In your very first message you’re saying that BackendlessCollection is null, but here you’re saying that “the data itself is null”. What do you mean by “data itself”? Can you demonstrate it through the code?

Notice the following code from AsyncCallback:

@Override
public void handleResponse(BackendlessCollection&lt;VideoInfo&gt; videoInfoBackendlessCollection) {}

videoInfoBackendlessCollection.getData().size() gives 5. But if I try getTitle with videoInfoBackendlessCollection.getdata().getTitle, it gives me null.

What I mean from “the data itself” is the title, videoThumbnailUri, the Name and other member variables.

Obviously the api call has 5 columns returned but their content is null.

Could you export your data and email the created ZIP file to me? The data export is available at Manage > Export. Make sure to select all data tables and select the “include data types” checkbox. My email address is mark@backendless.com.

Thanks,
Mark

Sorry for delay.

I just sent you the exported data.

I really appreciate your support. Thank you.

I just rewrote the custom class “VideoTutorial” and also the data on the server. Now it’s working. Not sure what was the origin of the problem. Anyway, I really appreciate your great responding.

Regards

Oh, I just looked at my first post on this topic. And now I can see that the problem was because of the member variable names. All of them have the “m” prefix. Since the member variable names of the custom class and the server side collection column’s names must be the same.