Parse: How to set the pointer in Android?

In my current class, let's say I have a column that is a pointer to another class, say B. Can someone please tell me how I can set the value for this column in Android?

I tried to extract the required string from class B as a ParseObject and execute:

classAObject.put("column_name",classBParseObject); 

But this just creates an empty string in my class A without pointers. Any help in this regard is greatly appreciated.

+7
java android pointers
source share
2 answers

If you have a course ID object identifier for Computer Science, you need to save it using the createWithoutData method. So, let recap: you have a Student table with a CourseId column - this is a pointer to the course table, not the CourseId column in the Course table. You cannot point to a column; you are pointing to a table.

Therefore, when you create a new Student object, you need to save the pointer in the CourseId column for Computer Science. Say the Computer Science object ID object in your course table is "xyz123." You would do the following:

 ParseObject student = new ParseObject("Student"); student.put("CourseId", ParseObject.createWithoutData("Course", "xyz123") ); //...set other values for the student object student.saveInBackground(); 

Parse docs have what you need and more - check out the relational data section: https://parse.com/docs/android_guide#objects-pointers

+14
source share

If this is a custom class, use the following code (for example: "AnotherClass" is a custom class)

 classAObject.put("column_name", ParseObject.createWithoutData("AnotherClass", "abc123")); 

or if it is a Parse class such as User, Installations, etc., use this,

 classAObject.put("column_name", ParseObject.createWithoutData(ParseUser.class, "abc123")); 
+5
source share

All Articles