Skip to content
Related Articles

Related Articles

Improve Article

How to Connect Android App with Back4App?

  • Last Updated : 12 Mar, 2021
Geek Week

Back4App is another famous backend platform that provides backend services for different types of applications whether it may be web, android, or IOS devices. Back4App also provides us similar services to that of Firebase. We have seen using Firebase in Android App. In this article, we will take a look at adding Back4App in your Android App in Android Studio. We will be building a simple application in which we will be connecting our Android App with Back4App. 


Back4App is one of the finest and the most popular alternatives for Parse among the developer’s community. It’s an easy way to build, host, and manage apps using the open-source Parse Server. Based on the highly efficient open-source backend framework, Parse Server, Back4App has several rich functionalities:

  • Featured Parse Server: Back4App uses Parse Server as a core product as it is the finest framework for backend development which can help developers save precious time building an app.
  • Boosted Server Performance: It supports a smart database index, queries optimizers, auto-scaling, automated backups, and redundant storage capacity.
  • Easy Deployment: Back4app is a ready-to-go platform. You can set up your app in less than 5 minutes.
  • Real-time database and analytics: It provides real-time data storage and synchronization. Real-time analytics is a key feature.
  • Within your budget: Predictable pricing, transparent and easy-to-budget.
  • Great technical support team: The engineering support of Back4App is always available to help its users.

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependency and JitPack Repository

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.   

implementation “com.github.parse-community.Parse-SDK-Android:parse:1.26.0”

Add the JitPack repository to your build file. Add it to your root build.gradle at the end of repositories inside the allprojects{ } section.

allprojects {

 repositories {


   maven { url “” }



Now sync your project and we are ready to add Back4App to our app. 

Step 3: Adding permissions to the internet in the AndroidManifest.xml file

Navigate to the app > AndroidManifest.xml and add the below code to it. 


<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

Step 4: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 


<?xml version="1.0" encoding="utf-8"?>
    <!--text view for displaying the text 
        which we are going to pass in back4app-->
        android:text="Hello World!"
        android:textColor="@color/black" />

Step 5: Creating a new app in back4App 

Create a new account in back4App or you can simply sign in using your Google Account. After creating your new account you will get to see the below screen. Click on the first option to create a new app. The screenshot is shown below. 

After clicking on this option you have to enter the name of your application and click on Create option. You will get to see this option on the below screenshot. 

After you have created a new application it will take some time to create a new application. Once your app has been created you have to go to the left nav drawer and then click on the App Settings option > Security & Keys option to get the key and client id for your app. The screenshot for this option is given below. 

Step 6: Adding your App id and app client key in your strings.xml file

Navigate to the app > res > values > strings.xml file and add the below code to it. Add your original client id and app id in these strings. 


    <string name="app_name">GFG Parse</string>
    <string name="back4app_server_url"></string>
    <!-- Change the following strings as required -->
    <string name="back4app_app_id">Enter your app id here</string>
    <string name="back4app_client_key">Enter your client key here</string>

Step 7: Creating a new Java class for our Application 

Navigate to the app > java > your app’s package name > Right-click on it > New > Java class and name it as App and add the below code to it. Comments are added in the code to get to know in more detail. 


import com.parse.Parse;
public class App extends Application {
    public void onCreate() {
        // initializing our Parse application with 
        // our application id, client key and server url
        Parse.initialize(new Parse.Configuration.Builder(this)
                 // at last we are building our 
                 // parse with the above credentials

Step 8: Adding the name for our App class in our AndroidManifest.xml file 

Navigate to the app > AndroidManifest.xml file and inside your application tag on the first line. Add the below line of code. Along with that, we have to add metadata to our application in your Manifest file. Below is the complete code for the AndroidManifest.xml file. 


    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
    <!--Meta data for your file for server url-->
        android:value="@string/back4app_server_url" />
    <!--Meta data for your file for application id-->
        android:value="@string/back4app_app_id" />
    <!--Meta data for your file for client key-->
        android:value="@string/back4app_client_key" />

Step 9: Working with the file

Go to the file and refer to the following code. Below is the code for the file. Comments are added inside the code to understand the code in more detail.


import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.ParseObject;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        // creating and initializing variable for our text view.
        TextView textView = findViewById(;
        // creating a variable for parse object and setting name as First Class.
        ParseObject firstObject = new ParseObject("FirstClass");
        // on below line we are passing the message as key and value to our object.
        firstObject.put("message", "Hey ! Welcome to Geeks for Geeks. Parse is now connected");
        // on below line we are calling a 
        // method to save in background.
        firstObject.saveInBackground(e -> {
            // checking if the error is null or not.
            if (e != null) {
                // displaying error toast message on failure.
                Toast.makeText(this, "Fail to add data.." + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
            } else {
                // if the data is send successfully we are displaying that data in our text view on below line.
                // as we are passing our key as message so we are calling our data with the key.
                textView.setText(String.format("Data saved is : \n %s", firstObject.get("message")));

Now run your app and see the output of the app. Make sure you have added all the keys inside your strings.xml file. After running your app you can see the data has been added to the back4app server which is shown in the below screenshot. 


Check out the project on the below link:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :