difference between Httpclientpost and Httpclientget is that the HttpPost is to specify the data entity to commit, and the implementation here is like a map, so this is the most convenient way to have more parameters. listExample Public Staticstring loginbyhttpclientpost (string username,string password) {Try{HttpClient Client=Newdefaulthttpclient (); String Path= "Http://192.168.254.100:8080/web/LoginServlet"; HttpPost Post=NewHttpPost
handlertest extends androidtestcase {public void testjsongetpersons () {// obtain the file path file sd_files = environment in the current SD directory. getexternalstoragedirectory (); // get persons. path of the XML file. Here I have sdcard/data. jsonstring file_path = sd_files.getname () + file. separator + "data. JSON "; try {fileinputstream FCM = new fileinputstream (new file (file_path); jsonhandler =
Android learning path-data usage (1)
Today is the fourth day of Android learning. In the morning, I learned how to store and use data. Here, I will summarize the data in the morning.
Data storage is divided into four categories:
*
Android: Use LruCache to cache the data you want To Cache
Today, let's take a look at the cache technology. I believe everyone knows the importance of requesting network data during development. However, there are some outdated messages that only use one request, such as some news information, every time we enter the news interface, getting a new one from the In
The last few months have not done Android programming, gradually forget something. Recently, I'm looking for an Android job to keep picking up the old stuff. The company has no network since the beginning of the first move, until today the company has network access, the departments only began to work. Do not say these, the following begins today's body.JSON -formatted
Android Developers use the POST method to request and send data to the server.The GET method is described above. Now try POST#1. First, use a new servlet to process login requests
package com.wzw.servlet;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * Servle
4 data storage methods in Android:1.SharedPreference2.SQLite3.ContentProvider4.File 1.SharedPreference 1) Lightweight data storage mode a 2) is essentially an XML file that stores Key-value key-value pairs of data 3) to hold configuration information for an application's parameters/properties The Sharedpreference o
When data is transmitted between activities, in order to avoid the trouble, some values are often encapsulated into objects, and then the entire object is passed over. The parcelable interface and the serializable interface can be implemented when an object is uploaded.
0. Two interfaces are explained:
1) the serializable interface is supported by javase itself.
2) parcelable is a unique feature of Android,
I. Intent Functions
Intent is frequently used in Android. Whether it is page transfer, data transfer, or external callProgramIntent is required for all system functions.
Android has three basic components: Activity, service, and broadcastreceiver. They are all activated through the intent mechanism, and different types of components have different ways to tra
In the previous blog post, we demonstrated the intent to return data by demo, which we continue to demonstrate through a demo, given the importance of the intent to return the data.In this demo, we enter the user name and password in the other activity, the user clicks the Back button, returns to Mainactivity, the user name and password back, and displays in the Mainactivity TextView.1. In Activity_main.xml, add TextView and button.linearlayout xmlns:
I. Data storage File:
In android, you can create a file to save data on the storage device of the device or an external storage device. By default, files cannot be shared among different programs.
Context in android provides several methods for file operations.
1). openFileOutput (file name, operation mode ).
2). openF
JSON data parsing for Android developmentThis blog is mainly about the use of Google's Lib library Gson parsing JSON data, because Android's own JSON data parser can only be used in Android version 3.0 or more, if you need to use Gson, We need to add the Gson Lib library fi
1. Content ProviderSQLite saves each application's own database, which is inaccessible between application databases , and content Provider solves this problem.It stores data that can be accessed by individual applications, can create content Providerin its own application, or can directly use existing content Provider.2.ContentResolverContentresolver cr=context.getcontentresolver ();//Get the object through the ContextIn
contact information on the deviceContent://contacts/people/45 This URI returns a single result (contact record with ID 45 in the contact information)Although this query string format is common, it still seems a bit confusing. To do this, Android offers a range of helper classes (under the Android.provider package),It contains a lot of query strings in the form of class variables, which is easier for us to understand, so as above content://contacts/pe
. Here is another thread in the main thread.
New Thread (new Runnable () {@ Override public void run () {// code for getting data}). start ();
The following is the main activity code.1 package com. example. jsonanalysis; 2 3 import org. json. JSONArray; 4 import org. json. JSONObject; 5 6 import android. OS. bundle; 7 import android. app. activity; 8 import
Several ways to transmit data with Intent
Click here to obtain the complete code
In addition to returning data from an activity, we often need to transmit data to the activity. For this purpose, we can use the Intent object to pass the data to the target activity.
1. Create a project named PassingData and add a
As a complete application, data storage operations are essential, so the Android system provides four ways to store data: Sharedpreference, File, SQLite, and content Provider. As the Android system, the data are basically private, are stored in the "
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.