First Parse Application

Now you know what is Parse, how to get it and you have also initialized data in the Parse cloud that is going to be used by your Android application

You have also initialized Parse in your Android application using the initialize Parse code snippet

Now building the application is simple

  • Parse requires a call to the data on the cloud and therefore as we learnt earlier, we have to make this call asynchronously – you need a AsyncTask. Look at the private class RemoteDataTask  that extends AsyncTask
  • Learn to use the query language – it is simple :
  • the rest of the steps are the same as you would do in a typical application – you have access to the data dynamically, build the adapter and associate the adapter to the view, do all this in in onPostExecute method
  • Enable internet access on your AndroidManifest file – <uses-permission android:name=”android.permission.INTERNET” />

public class MainActivity extends Activity {

private ListView categoryListView;
private ArrayAdapter<String> categoryListAdapter;
private List<ParseObject> categories;
private ArrayList<String> categoryList = new ArrayList<String>();

public void onCreate(Bundle savedInstanceState) {
new RemoteDataTask().execute();


public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(, menu);
return true;

private void initializeParse() {
Parse.initialize(this, “NDUawcm7DwXAkkSnuLMMiG6waq7l2RgOOu6YOpZB”,
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);

private class RemoteDataTask extends
android.os.AsyncTask<Void, Void, Void> {
// Override this method to do custom remote calls
protected Void doInBackground(Void… params) {
// Gets the current list of Categories in sorted order
ParseQuery query = new ParseQuery(“Categories”);

try {
categories = query.find();
} catch (ParseException e) {
Log.e(“MainActivity:RemoteDataTask:doInBackground:Exception Retrieving Categories:”,

return null;

protected void onPostExecute(Void result) {
// Put the list of categories into the list view
for (ParseObject category : categories) {
categoryList.add((String) category.get(“Name”));
categoryListView = (ListView) findViewById(;
categoryListAdapter = new ArrayAdapter<String>(MainActivity.this,
R.layout.activity_main,, categoryList);




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: