Android platform HttpClient-Mobile phone number attribution to the query

Source: Internet
Author: User
Tags html tags http post http request sqlite sqlite database

The Android platform offers four types of data storage: Shared Preferences, file storage, SQLite storage, and networked storage. which

1 Shared Preferences A lightweight key-value storage mechanism dedicated to storing key-value pairs of data, and can only store basic data types (boolean, int, long, float, and string), which are typically used to store application configuration information.

2 file storage operates on files through FileInputStream and FileOutputStream, and in Android, files are proprietary to an application, and an application cannot read or write to other application files.

3) SQLite Storage SQLite is a lightweight database that supports standard SQL. Its design goal is embedded, occupy the resource very low, in the embedded device, only need hundreds of K of memory is enough. The Android platform also provides us with a SQLite database.

4 Network Storage The above 3 kinds of data are stored on the mobile phone, while the data stored in the network is stored on the remote server, the mobile client connects to the network to store and retrieve the data.

HttpClient is one of the most common networked storage tools to be explained today. Remember the first contact httpclient was two years ago, when to do a vertical search engine, the data is naturally derived from the Internet, through a crawler system from the designated site to crawl the interest of data, and then through the Lucene search engine framework to achieve a large number of data fast retrieval. The crawler system is to use the open source of the crawler framework Heritrix to achieve, but after a period of contact found Heritrix too large, but also as a stand-alone system running, not convenient to embed into the existing system, coupled with high learning costs, and finally chose the "HttpClient + Htmlparser "To implement a small reptile system in which httpclient can simulate HTTP post and get requests for Web page data from a specified Web site, while Htmlparser is used to parse crawled pages, filter HTML tags, and obtain final data.

Did you find out that httpclient is quite powerful? Let's see what it is. "HttpClient is a subproject under Apache Jakarta Common that can be used to provide efficient, up-to-date, feature-rich client-side programming toolkits that support HTTP protocols, and it supports the latest versions and recommendations of the HTTP protocol." If you haven't contacted HttpClient before, then you just need to remember two points simply: 1 HttpClient is an HTTP protocol development package; 2 HttpClient is not a patent for Android.

HttpClient's function Introduction:

1 implement all the methods of HTTP request (such as GET, POST, put, head, etc.);

2) support automatic steering;

3) Support HTTPS protocol;

4) Support Proxy server, etc.

Basic use of httpclient (as an example of a POST request):

1 Create HttpClient instance (similar to browser client);

HttpClient client = new Defaulthttpclient ();

2 Create the HttpPost request, you need to pass the requested URL to the HttpPost construction method;

HttpPost post = new HttpPost (Requesturl);

3 Send a POST request (Invoke HttpClient Execute () method, execute () parameter is HttpPost instance);

HttpResponse response = Client.execute (POST);

4) Read the return result;

5) releasing the 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.