Android

Parse Objects - CRUD

Introduction

This section explains how you can use Parse Android SDK to manage Parse Objects at Back4App. When you store data on Parse it is built around ParseObject and each one contains key-value pairs of JSON-compatible data.

The data options to be storage in Back4App Database can be strings, numbers, booleans, or even arrays and objects - anything that can be JSON-encoded.

This guide contains the basics operations to manage objects, it’s a simple CRUD that means Create, Read, Update and Delete objects. With 4 steps, you will be able to perform the four basic functions of persistent storage. In sume, we will develop three new activities screens to Create, Update and Read/Delete Objects.

Note: We will use the User Registration guide to build the Login Activity.

Prerequisites

To complete this tutorial, you need:

  • Android Studio
  • An app created on Back4App.
  • An android app connected to Back4app.
  • A device (or virtual device) running Android 4.0 (Ice Cream Sandwich) or newer.

Let’s get started!

Following the next steps you will be able to build a Reminder App that will storage the commitments at Back4App Database.

Note: All Java Code that will be implemented and explained, we will show them in 2 different tabs on the modals, they are: Imported Classes and Main Code.

Understanding our App

After configuring the initial activities (Login and Sign Up) availables on the User Registration/Login tutorial, now go to your Parse Dashboard and create a class called reminderList. Inside that class, we will need to create the following Columns and respective type:

  • itemName (String)
  • additionalInformation (String)
  • dateCommitment (Date)
  • isAvailable (Boolean)

Step 1 - Read and Delete Objects

Go to Android Studio, access the main folder from the Project (Project > app > java > Main Project) and then to create a new Activity click the right mouse button and select the option New > Activity > Empty Activity > ReadObjects), the same process is demonstrated below:

Step 1.1 - Add depencency

First off, to improve our Design and insert an Floatting button into our Activity, go at the build.grandle and insert the code below:

./app/build.grandle

implementation 'com.android.support:design:REPLACE-WITH-APPCOMPAT-VERSION'

Step 1.2 - Design Code

Open the activity_read_objects.xml file in text view and add the following code snippet:

./app/src/main/res/layout/activity_read_objects.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible"
    tools:context=".ReadObjects">

    <ListView
        android:id="@+id/listviewA"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="0dp"
        android:layout_centerVertical="true"
        android:visibility="visible"
        android:scrollingCache="false"/>


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_menu_add"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:theme="@style/MyFloatingButton" />

</android.support.design.widget.CoordinatorLayout>

Go back to your Android Studio Project, open your dimens file and paste the code below:

.../app/src/main/res/values/dimens.xml

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="fab_margin">16dp</dimen>
</resources>

Also, open your styles file and add the style configuration below:

.../app/src/main/res/values/styles.xml

1
2
3
<style name="MyFloatingButton" parent="Theme.AppCompat.Light">
    <item name="colorAccent">@color/colorAccent</item>
</style>

Step 1.3 - Logic Code

In this Activity, we will retrieve all items based on the Current User with an equalTo Condition, with then construct an ArrayList to show at the view these matched items. Now, we will implement the Logic inside the ReadObjects.class:

At the beginning of the activity, import the following:

imports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.parse.DeleteCallback;
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Main Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
public class ReadObjects extends AppCompatActivity {

    public ArrayList<String> dataList = new ArrayList<String>();
    public String[] myArray = {};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_read_objects);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ReadObjects.this, CreateObject.class);
                startActivity(intent);
            }
        });

        findObjects();
    }

     private void findObjects(){
        myArray = new String[]{};
        final ListView listView = (ListView) findViewById(R.id.listviewA);

        // Configure Query 
        ParseQuery<ParseObject> query = ParseQuery.getQuery("reminderList");

        // Query Parameters
        query.whereEqualTo("userId", ParseUser.getCurrentUser());

        // Sorts the results in ascending order by the itemName field
        query.orderByAscending("itemName");

        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, final ParseException e) {
                if (e == null){
                    // Adding objects into the Array
                    for(int i= 0 ; i < objects.size(); i++){
                        String element = objects.get(i).getString("itemName");
                        dataList.add(element.toString());
                    }
                } else {

                }
                myArray = dataList.toArray(new String[dataList.size()]);

                final ArrayList<String> list  = new ArrayList<String>(Arrays.asList(myArray));

                ArrayAdapter<String> adapterList
                        = new ArrayAdapter<String>(ReadObjects.this, android.R.layout.simple_list_item_single_choice, myArray);

                listView.setAdapter(adapterList);
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(final AdapterView<?> adapter, View v, final int position,
                                            long id) {

                        final String value = (String) adapter.getItemAtPosition(position);

                        //Alert showing the options related with the object (Update or Delete)
                        AlertDialog.Builder builder = new AlertDialog.Builder(ReadObjects.this)
                                .setTitle(value + " movie" )
                                .setMessage("What do you want to do?")
                                .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dataList.remove(position);
                                        deleteObject(value);
                                        myArray = dataList.toArray(new String[dataList.size()]);

                                        ArrayAdapter<String> adapterList
                                                = new ArrayAdapter<String>(ReadObjects.this, android.R.layout.simple_list_item_single_choice, myArray);

                                        listView.setAdapter(adapterList);
                                    }
                                })
                                .setNeutralButton("Update",  new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent intent = new Intent(ReadObjects.this, UpdateObject.class);
                                        //Send string value to UpdateObject Activity with putExtra Method
                                        intent.putExtra("objectName", value.toString());
                                        startActivity(intent);
                                    }
                                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        dialog.cancel();
                                    }
                                });
                        AlertDialog ok = builder.create();
                        ok.show();
                    }
                });
            }
        });
    }

    // Delete object
    private void deleteObject(final String value) {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("reminderList");

        // Query parameters based on the item name
        query.whereEqualTo("itemName", value.toString());
        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(final List<ParseObject> object, ParseException e) {
                if (e == null) {
                	//Delete based on the position
                    object.get(0).deleteInBackground(new DeleteCallback() {
                        @Override
                        public void done(ParseException e) {
                            if (e == null) {

                            } else {
                            	Toast.makeText(
								    getApplicationContext(),
								    e.getMessage().toString(),
								    Toast.LENGTH_LONG
								).show();
                            }
                        }
                    });
                } else {
                	Toast.makeText(
                        getApplicationContext(),
                        e.getMessage().toString(),
                        Toast.LENGTH_LONG
                	).show();
                }
            };
        });
    }    
}


In short, this class is listing objects based on an objectId of the logged-in user.

Step 2 - Create Objects

Until this step, we’re able to list all content related with the Current User logged-in our App, as you can see on the Step 1, we’ve configured an Float Button to the user click and call this new Activity to create an object. We will show to you the Logic and Design from this new Activity.

2.1 - Design Code

First off, you need to implement your design with the fields, please paste the code below inside the CreateObject layout:

.../app/src/main/res/layout/activity_create_objects.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:layout_alignParentTop="true"
    tools:layout_alignParentStart="true"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    tools:context=".CreateObject">

    <TextView
        android:id="@+id/txtItem"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Item ToDo"
        android:layout_marginTop="15dp"/>

    <EditText
        android:id="@+id/edtItem"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:maxLines="1"
        android:singleLine="true" />

    <TextView
        android:id="@+id/txtAdd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Additional Information"
        android:layout_marginTop="15dp"/>

    <EditText
        android:id="@+id/edtAdditionalInformation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:maxLines="3"
        android:singleLine="true" />

    <Switch
        android:id="@+id/swiAvailable"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Is it available?"
        android:layout_marginTop="15dp"/>

    <TextView
        android:id="@+id/txtDate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Reminder Date"
        android:layout_marginTop="15dp"/>

    <CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"/>

    <Button
        android:id="@+id/btnCreate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Create Item" />

</LinearLayout>

Step 2.1 - Logic Code

And now, following the first step, we’re able to create an new Screen called as CreateObject. Next, you can insert the code below inside your JAVA file:

At the beginning of the activity, import the following:

imports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;

import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import com.parse.SaveCallback;

import java.text.SimpleDateFormat;
import java.util.Date;

Main Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
public class CreateObject extends AppCompatActivity {
    private EditText itemName;
    private EditText itemAdd;
    private CalendarView itemDate;
    private Button create_button;
    private Switch isAvailable;
    private Date formatterDate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_object);

        itemName = (EditText) findViewById(R.id.edtItem);
        itemAdd = (EditText) findViewById(R.id.edtAdditionalInformation);
        itemDate = (CalendarView) findViewById(R.id.calendarView);
        create_button = findViewById(R.id.btnCreate);
        isAvailable = (Switch) findViewById(R.id.swiAvailable);
        // Get Date from CalendarView
        itemDate.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
            public void onSelectedDayChange(CalendarView calendarView, int year, int month, int dayOfMonth) {
                String getDate = (dayOfMonth + "/" + (month+1) + "/" + year);
                formatterDate = convertStringToData(getDate);
            }
        });

        create_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Validating the log in data
                boolean validationError = false;

                StringBuilder validationErrorMessage = new StringBuilder("Please, ");
                if (isEmptyText(itemName)) {
                    validationError = true;
                    validationErrorMessage.append("insert an name");
                }
                if (isEmptyDate()) {
                    if (validationError) {
                        validationErrorMessage.append(" and ");
                    }
                    validationError = true;
                    validationErrorMessage.append("select a Date");
                }
                validationErrorMessage.append(".");
                if (validationError) {
                    Toast.makeText(CreateObject.this, validationErrorMessage.toString(), Toast.LENGTH_LONG).show();
                    return;
                } else {
                    saveObject();
                }
            }
        });
    }
    public static Date convertStringToData(String getDate){
        Date today = null;
        SimpleDateFormat simpleDate = new SimpleDateFormat("dd/MM/yyyy");

        try {
            today = simpleDate.parse(getDate);
        } catch (java.text.ParseException e) {
            e.printStackTrace();
        }
        return today;
    }
    private boolean isEmptyText(EditText text) {
        if (text.getText().toString().trim().length() > 0) {
            return false;
        } else {
            return true;
        }
    }
    private boolean isEmptyDate() {
        if (String.valueOf(formatterDate) != "null") {
            return false;
        } else {
            return true;
        }
    }
    public void saveObject(){
    	// Configure Query
        ParseObject reminderList = new ParseObject("reminderList");

        // Store an object 
        reminderList.put("itemName", itemName.getText().toString());
        reminderList.put("additionalInformation", itemAdd.getText().toString());
        reminderList.put("dateCommitment", formatterDate);
        reminderList.put("isAvailable", isAvailable.isChecked());
        reminderList.put("userId", ParseUser.getCurrentUser());
        
        // Saving object
        reminderList.saveInBackground(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Intent intent = new Intent(CreateObject.this, ReadObjects.class);
                    startActivity(intent);
                } else {
                    Toast.makeText(
                            getApplicationContext(),
                            e.getMessage().toString(),
                            Toast.LENGTH_LONG
                    ).show();
                }
            }
        });
    }
}

Step 3 - Update Objects

In this section, we will show you know how to update a Object throgh the Parse Android SDK. As the first step, related to listing objects, in this step we will filter and so update them based on the String value. Following the first step, you can create a New Activity called as UpdateObject, after that, you can go to the step below:

Step 3.1 - Design Code

Go to your UpdateObject Activity and open the activity_update_object.xml file in text view and add the following code snippet:

./app/src/main/res/layout/activity_update_object.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    tools:context=".UpdateObject">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:layout_alignParentTop="true"
        tools:layout_alignParentStart="true">

        <TextView
            android:id="@+id/txtItem"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Item ToDo"
            android:layout_marginTop="15dp"/>

        <EditText
            android:id="@+id/edtItem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:maxLines="1"
            android:singleLine="true" />

        <TextView
            android:id="@+id/txtAdd"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Additional Information"
            android:layout_marginTop="15dp"/>

        <EditText
            android:id="@+id/edtAdditionalInformation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="text"
            android:maxLines="1"
            android:singleLine="true" />

        <Switch
            android:id="@+id/swiAvailable"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Is it available?"
            android:layout_marginTop="15dp"/>

        <TextView
            android:id="@+id/txtDate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Reminder Date"
            android:layout_marginTop="15dp"/>

        <CalendarView
            android:id="@+id/calendarView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"/>

        <Button
            android:id="@+id/btnCreate"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Update Item" />
    </LinearLayout>
</ScrollView>

Step 3.2 - Logic Code

Also, you need to create a new Activity called as UpdateObject and use the Logic Code below:

At the beginning of the activity, import the following:

imports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.Toast;

import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import com.parse.SaveCallback;

import java.text.SimpleDateFormat;
import java.util.Date;

Main Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
public class UpdateObject extends AppCompatActivity {
    private EditText itemName;
    private EditText itemAdd;
    private Switch itemAvailable;
    private CalendarView itemCalendary;
    private Date formatterDate;
    private String getObjectId;

    private Button create_button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_update_object);
        create_button = (Button) findViewById(R.id.btnCreate);
        itemName = (EditText) findViewById(R.id.edtItem);
        itemAdd = (EditText) findViewById(R.id.edtAdditionalInformation);
        itemAvailable = (Switch) findViewById(R.id.swiAvailable);
        itemCalendary = (CalendarView) findViewById(R.id.calendarView);

        // Defining event to Calendar
        itemCalendary.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
            public void onSelectedDayChange(CalendarView calendarView, int year, int month, int dayOfMonth) {
                String getDate = (dayOfMonth + "/" + (month+1) + "/" + year);
                formatterDate = convertStringToData(getDate);
            }
        });

        final Intent element = getIntent();

        // Recover string from other activity
        final String objectName = element.getStringExtra("objectName").toString();

        create_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                saveObject();
            }
        });
        
        // Recover the CurrentUser Id with the getObjectId method
        String currentUser = ParseUser.getCurrentUser().getObjectId();
        // 
        final ParseObject obj = ParseObject.createWithoutData("_User",currentUser);

        //Configure Query
        ParseQuery<ParseObject> query = ParseQuery.getQuery("reminderList");

        // Query Parameters        
        query.whereEqualTo("userId", obj);
        query.whereEqualTo("itemName", objectName);

        // How we need retrive exactly one result we can use the getFirstInBackground method
        query.getFirstInBackground(new GetCallback<ParseObject>() {
            public void done(ParseObject object, ParseException e) {
                if (e == null) {
                    try {
                        itemCalendary.setDate(makeLongTODate(object.getDate("dateCommitment")), true, true);
                    } catch (java.text.ParseException e1) {
                        e1.printStackTrace();
                    }
                    // Insert the retrieve Content inside the Input at the view
                    itemName.setText(objectName);
                    itemAdd.setText(object.getString("additionalInformation"));
                    itemAvailable.setChecked(object.getBoolean("isAvailable"));
                    getObjectId = object.getObjectId().toString();
                } else {
                	Toast.makeText(
                        getApplicationContext(),
                        e.getMessage().toString(),
                        Toast.LENGTH_LONG
                    ).show();
                }
            }
        });
    }
     public static Date convertStringToData(String getDate){
        Date today = null;
        SimpleDateFormat simpleDate = new SimpleDateFormat("dd/MM/yyyy");

        try {
            today = simpleDate.parse(getDate);
        } catch (java.text.ParseException e) {
            e.printStackTrace();
        }
        return today;
    }
    public static long makeLongTODate(Date dateTime) throws java.text.ParseException {
        String d1 = null;
        try {
            d1 = new SimpleDateFormat("dd/MM/yyyy")
                    .format(new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy")
                            .parse(String.valueOf(dateTime)));
        } catch (java.text.ParseException e) {
            e.printStackTrace();
        }

        long result = new SimpleDateFormat("dd/MM/yyyy").parse(d1).getTime();

        return result;

    }
    public void saveObject(){
        final Editable itemNameUpdate = itemName.getText();
        final Editable itemAddUpdate = itemAdd.getText();
        final Boolean isAvailableUpdate = itemAvailable.isChecked();


        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
        final String selectedDate = sdf.format(new Date(itemCalendary.getDate()));

        final Date formatterDateHere = convertStringToData(selectedDate);

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

        // Retrieve the object by id
        query.getInBackground(getObjectId, new GetCallback<ParseObject>() {
            public void done(ParseObject reminderList, ParseException e) {
                if (e == null) {
                    reminderList.put("itemName", itemNameUpdate.toString());
                    reminderList.put("additionalInformation", itemAddUpdate.toString());
                    if (formatterDate != null) {
                        reminderList.put("dateCommitment", formatterDate);
                    }
                    reminderList.put("isAvailable", isAvailableUpdate);
                    reminderList.saveInBackground(new SaveCallback() {
                        @Override
                        public void done(ParseException e) {
                            if (e == null) {
                                Intent intent = new Intent(UpdateObject.this, ReadObjects.class);
                                startActivity(intent);
                            } else {
                                Toast.makeText(
                                        getApplicationContext(),
                                        e.getMessage().toString(),
                                        Toast.LENGTH_LONG
                                ).show();
                            }
                        }
                    });
                } else {
                	Toast.makeText(
                        getApplicationContext(),
                        e.getMessage().toString(),
                        Toast.LENGTH_LONG
                	).show();
                }
            }
        });
    }
}


In short, this class finds the object based on the name and saves the possible changes added.

Step 4 - Testing our App

By this time, your Android code should be working properly. After navigate on the activities, it should easily Create, Read, Update and Delete objects and then refresh our Database. Your app will look like the picture below:

App working in Back4App!

It’s done!

With the guide described above, you’ll be able to CRUD objects trough the Parse Android SDK ! In case you need any help or a function/link doesn’t work, please contact our team via chat!