Parse cloud-based services for Android applications

Source: Internet
Author: User
Tags arrays json map class table name

The Parse Mobile SDK delivers cloud-based APIs and services for IOS, Android, and Windows applications. The Parse SDK also provides JavaScript and REST APIs. With the Parse API, you can quickly and with minimal effort allow your mobile applications to support cloud processing. Mobile applications that integrate the Parse API can easily store data objects and files on the Parse cloud, send and listen for push notifications, manage users, process geographic data, and use social media platforms such as Twitter and Facebook. For mobile applications that need to be expanded, the Parse SDK provides all the flexible cloud platforms.

This article describes the core Parse API classes for Parse users, data objects, and files. You will learn how to use Access control lists (ACLs), how to perform CRUD operations on data objects, and how to store and retrieve files in the Parse cloud. Examples are built on the Parse SDK for Android.

Parse instrument panel

The Parse Dashboard can help developers manage applications. The dashboard provides general metrics and application-specific usage metrics for APIs, files, and push notifications. The dashboard allows you to manage keys and settings for your application. The dashboard also provides a data browser that enables developers to browse (and even edit) Parse objects that are stored. Data browsers are useful for debugging. Figure 1 is a screenshot of the Parse dashboard:

Figure 1. Parse instrument panel

The application is authenticated with an application ID and a client ID. In order to obtain your application and client ID, you must register your application through the Parse dashboard. These keys are used when initializing the Parse library on your application.

Parse Data Objects

In Parse, the container parseobject of the name-value pair is used to represent the data. Parseobject can store any JSON-compatible data, as shown in Listing 1:

Listing 1. Parseobject sample

Parseobject myparseobject = new 

parseobject ("MyObject");//Class name
myparseobject.put ("name", "C. Enrique Ortiz ");
Myparseobject.put ("Twitterhandle", "Eortiz");
Myparseobject.put ("followers", 123456);

Parseobject is given a classname (class name) when instantiated. In Listing 1, the class name is "MyObject". A class name is similar to a table name in a relational database, and a Parse object of the same class corresponds to a row in a table.

Parseobject exposure is similar to methods in the Java Map class, such as put, get, and remove, and a large number of other parseobject-specific methods.

The Parseobject name key must be alphanumeric, and as a guideline, use the camel-case (camel-casing) format for the name keys. The value can be any data type stored in JSON, that is, it can be numbers, strings, booleans, arrays, Jsonobject.null, Jsonobject, and Jsonarray. Other data types supported by Parseobject are the Java Date and byte[] arrays. Parseobject can also contain other parseobject.

Listing 2 shows some of the supported Parseobject value data types:

Listing 2. Parseobject: Partially supported Value data types

//Byte Array byte[] ByteArray = {1, 2, 3, 4, 5}; A Date D = new Date ();
    
Java.util.Date//A number int number = 21;
    
A String String name = "Enrique";
A Jsonarray-any mix of jsonobjects, Jsonarrays, Strings, booleans,//integers, longs, doubles, null or NULL.
Jsonarray Jarray = new Jsonarray ();
Jarray.put (number);
    
Jarray.put (name);
A jsonobject jsonobject jobject = new Jsonobject ();
    try {jobject.put ("number", number);
Jobject.put ("name", name);
    
catch (Jsonexception e) {e.printstacktrace ();} A parseobject parseobject pobject = new Parseobject ("MyObject");
Class name Pobject.put ("Mybytearray", ByteArray);
Pobject.put ("MyDate", D);
Pobject.put ("myString", name);
Pobject.put ("MyNumber", number);
Pobject.put ("Myjsonarray", Jarray);
Pobject.put ("Myjsonobject", jobject); Pobject.put ("Mynull", jsonobject.null); 

The code in Listing 2 creates a parseobject that is stored as an object in the Parse cloud. Many of the same categories of MyObject are then stored as rows of parseobject data objects that can be saved, queried, and updated and removed from Parse cloud storage. You can even save data while the application is offline, and the Parse library saves the data locally until you re-establish the network connection.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.