简体   繁体   中英

Retrieving Objects From Parse.com

I am having issued Retrieving objects from Parse.com. I plan to have a list of anywhere from 3 to 25 objects displayed, They will change daily. I will not know the ObjectID , or any of the content of the object. I followed this guide the best I could.

I wrote this code here to simplify what I am doing. It is throwing a null pointer exception in my .done .

UPDATED

Saving my object: //I am doing this successfully

            ParseObject testObject = new ParseObject("TestObject");
            testObject.put("TheColumn", "The name in the column");
            testObject.saveInBackground();
            Context context = getApplicationContext();
            Toast toast = Toast.makeText(context, "Saved", Toast.LENGTH_LONG);
            toast.show();

Retrieving my Object //Unsuccessfully....

          ParseQuery<ParseObject> query  = ParseQuery.getQuery("TestObject");

            query.findInBackground(new FindCallback<ParseObject>() {
                @Override
                public void done(List<ParseObject> parseObjects, com.parse.ParseException e) {
                    if (e==null){

                        Log.d("THE OBJECT", "" +parseObjects.size());


                        name =  parseObjects.toString();
                        Log.d("THE QUERY ", "" + name);

                    } else {
                        Log.d("ERROR:", "" + e.getMessage());
                    }
                }
            });

In my logcat, I get my Log.d 's to log. I get two; D/THE OBJECT: 1 and D/THE QUERY: [com.parse.ParseObject@XXXXXX] But if I try to set it to a TextView , I get a nullPointerException .

Why am I getting data returned like this? I feel I am following this guide closely.

The Reason for my nullpointer was that I was setting the text to a TextView in a different class on accident. Got my r.id 's confused.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM