java - not able to retrieve string from parse database with query -
i'm trying retrieve information parse object strings store them in keep equaling null.
here how saved object
// current user parseobject studentclasses = new parseobject("studentclasses"); // register periods database studentclasses.put("student_id", parseuser.getcurrentuser()); studentclasses.put("first_period", classselected_period[period1]); studentclasses.put("second_period", classselected_period[period2]); studentclasses.put("third_period", classselected_period[period3]); studentclasses.put("fourth_period", classselected_period[period4]); studentclasses.put("fifth_period", classselected_period[period5]); studentclasses.put("sixth_period", classselected_period[period6]); studentclasses.put("seventh_period", classselected_period[period7]); // save information database studentclasses.saveinbackground();
it saves fine database. student_id pointer user , rest of columns strings.
i want retrieve strings , put them in array when query parse them doesn't work
here query
// check if user not cached parseuser currentuser = parseuser.getcurrentuser(); if (currentuser == null) { // prompt user register screen // create intent start activity intent intent = new intent(mainactivity.this, registeractivity.class); intent.addflags(intent.flag_activity_clear_top); // start new activity startactivity(intent); // stop current activity finish(); } // query database user's classes parsequery<parseobject> query = parsequery.getquery("studentclasses"); query.whereequalto("student_id", parseuser.getcurrentuser()); query.getfirstinbackground(new getcallback<parseobject>() { @override public void done (parseobject parseobject, parseexception e) { if (e == null) { // retrieved object userclasses[period1] = parseobject.getstring("first_period"); userclasses[period2] = parseobject.getstring("second_period"); userclasses[period3] = parseobject.getstring("third_period"); userclasses[period4] = parseobject.getstring("fourth_period"); userclasses[period5] = parseobject.getstring("fifth_period"); userclasses[period6] = parseobject.getstring("sixth_period"); userclasses[period7] = parseobject.getstring("seventh_period"); } else { // failed lookup. here toast.maketext(getapplicationcontext(),"exception thrown" ,toast.length_short).show(); } } });
i looked @ parse docs , looks should work doesn't save strings
any or comments appreciated thanks!
edit: showed more of code query part show there current user
here assuming that, there data stored in parse database.. , works fine.. retrieve try following..
parsequery<parseobject> query = parsequery.getquery("studentclasses"); query.whereequalto("student_id", parseuser.getcurrentuser()); query.findinbackground(new findcallback<parseobject>() { @override public void done (list<parseobject> list, parseexception e) { if (e == null) { for(int i=0; < list.size(); i++) { userclasses[period1] = list.get(i).getstring("first_period"); userclasses[period2] = list.get(i).getstring("second_period"); userclasses[period3] = list.get(i).getstring("third_period"); userclasses[period4] = list.get(i).getstring("fourth_period"); userclasses[period5] = list.get(i).getstring("fifth_period"); userclasses[period6] = list.get(i).getstring("sixth_period"); userclasses[period7] = list.get(i).getstring("seventh_period"); } } else { toast.maketext(getapplicationcontext(),"exception thrown" ,toast.length_short).show(); } } });
hope helps!
Comments
Post a Comment