I've been trying to add Parse to my android app. Everything is fine setting it up. Adding certain data to the cloud and users etc. I'm trying to add data from an classes ArrayList that sends out params. The Class Collection from the arraylist is fine which is called Tasks. It has the correct information. I set up a new class which extends the ParseObject, which is below, that should fill in for the Tasks class to enter the data to the Parse Cloud.
package beans;
import com.parse.ParseClassName;
import com.parse.ParseObject;
import com.parse.ParseUser;
import java.util.ArrayList;
/**
* Created by KieranMcc on 11/01/2016.
*/
@ParseClassName("Tasks")
public class ParseTasks extends ParseObject {
private int id; //_id
private int task_id; //task_id
private String task; //task_name
private boolean completed; //_isCompleted
public ParseTasks(){
super();
}
public ParseTasks(Tasks tasks){
super();
}
public int getId() {
return getInt("_id");
}
public void setId(int id) {
put("_id", id);
}
public int getTask_id() {
return getInt("task_id");
}
public void setTask_id(int task_id) {
put("task_id", task_id);
}
public String getTask() {
return getString("task_name");
}
public void setTask(String task) {
put("task_name", task);
}
public boolean isCompleted() {
return getBoolean("_isCompleted");
}
public void setCompleted(boolean completed) {
put("_isCompleted", completed);
}
public void setUser(ParseUser user){
put("tasks_user", user);
}
public ParseUser getUser(){
return getParseUser("task_user");
}
}
What I'm trying to do is loop through the arraylist with a collection of the class Tasks. ArrayList
This is my code but it isn't saving to Parse
protected void uploadToCloud(Task task){
ParseTask taskParse = new ParseTask();
taskParse.setUser(ParseUser.getCurrentUser());
taskParse.setId(task.getId());
taskParse.setName(task.getName());
taskParse.setNumOfTasks(task.getNumOfTasks());
taskParse.setNumOfTasksCompleted(task.getNumOfTasksCompleted());
taskParse.saveInBackground();
// add task to cloud
// loop through tasks and add one by one to cloud
ParseTasks tasksParse= new ParseTasks();
for(int i = 0; i < task.getTasks().size(); i++){
tasksParse.setId(task.getTasks().get(i).getId());
tasksParse.setTask(task.getTasks().get(i).getTask());
tasksParse.setTask_id(task.getTasks().get(i).getTaskId());
tasksParse.setCompleted(false);
tasksParse.setUser(ParseUser.getCurrentUser());
tasksParse.saveInBackground();
}
}
Not quite sure what i'm doing wrong as I don't get an error or anything. And the ParseTask about goes through fine? Can someone tell me why it wont go through please. Thank you very much for reading over the long post and for any help :)