Content Providers的步骤,来自官网文档
Content Providers
Content providers store and retrieve data and make it accessible to all applications. They're the only way to share data across applications; there's no common storage area that all Android packages can access.
Android ships with a number of content providers for common data types (audio, video, images, personal contact information, and so on). You can see some of them listed in theandroid.provider
package. You can query these providers for the data they contain (although, for some, you must acquire the proper permission to read the data).
If you want to make your own data public, you have two options: You can create your own content provider (a ContentProvider
subclass) or you can add the data to an existing provider — if there's one that controls the same type of data and you have permission to write to it.
This document is an introduction to using content providers. After a brief discussion of the fundamentals, it explores how to query a content provider, how to modify data controlled by a provider, and how to create a content provider of your own.
Content Provider Basics
How a content provider actually stores its data under the covers is up to its designer. But all content providers implement a common interface for querying the provider and returning results — as well as for adding, altering, and deleting data.
It's an interface that clients use indirectly, most generally through ContentResolver
objects. You get a ContentResolver by calling
from within the implementation of an Activity or other application component:getContentResolver()
ContentResolver cr = getContentResolver();
You can then use the ContentResolver's methods to interact with whatever content providers you're interested in.
When a query is initiated, the Android system identifies the content provider that's the target of the query and makes sure that it is up and running. The system instantiates all ContentProvider objects; you never need to do it on your own. In fact, you never deal directly with ContentProvider objects at all. Typically, there's just a single instance of each type of ContentProvider. But it can communicate with multiple ContentResolver objects in different applications and processes. The interaction between processes is handled by the ContentResolver and ContentProvider classes.
The data model
Content providers expose their data as a simple table on a database model, where each row is a record and each column is data of a particular type and meaning. For example, information about people and their phone numbers might be exposed as follows:
_ID | NUMBER | NUMBER_KEY | LABEL | NAME | TYPE |
---|---|---|---|---|---|
13 | (425) 555 6677 | 425 555 6677 | Kirkland office | Bully Pulpit | TYPE_WORK |
44 | (212) 555-1234 | 212 555 1234 | NY apartment | Alan Vain | TYPE_HOME |
45 | (212) 555-6657 | 212 555 6657 | Downtown office | Alan Vain | TYPE_MOBILE |
53 | 201.555.4433 | 201 555 4433 | Love Nest | Rex Cars | TYPE_HOME |
Every record includes a numeric _ID
field that uniquely identifies the record within the table. IDs can be used to match records in related tables — for example, to find a person's phone number in one table and pictures of that person in another.
A query returns a Cursor
object that can move from record to record and column to column to read the contents of each field. It has specialized methods for reading each type of data. So, to read a field, you must know what type of data the field contains. (There's more on query results and Cursor objects later.)
URIs
Each content provider exposes a public URI (wrapped as a Uri
object) that uniquely identifies its data set. A content provider that controls multiple data sets (multiple tables) exposes a separate URI for each one. All URIs for providers begin with the string "content://
". The content:
scheme identifies the data as being controlled by a content provider.
If you're defining a content provider, it's a good idea to also define a constant for its URI, to simplify client code and make future updates cleaner. Android defines CONTENT_URI
constants for all the providers that come with the platform. For example, the URI for the table that matches phone numbers to people and the URI for the table that holds pictures of people (both controlled by the Contacts content provider) are:
android.provider.Contacts.Phones.CONTENT_URI
android.provider.Contacts.Photos.CONTENT_URI
The URI constant is used in all interactions with the content provider. Every ContentResolver
method takes the URI as its first argument. It's what identifies which provider the ContentResolver should talk to and which table of the provider is being targeted.
Querying a Content Provider
You need three pieces of information to query a content provider:
- The URI that identifies the provider
- The names of the data fields you want to receive
- The data types for those fields
If you're querying a particular record, you also need the ID for that record.
Making the query
To query a content provider, you can use either the
method or the ContentResolver.query()
method. Both methods take the same set of arguments, and both return a Cursor object. However, Activity.managedQuery()
managedQuery()
causes the activity to manage the life cycle of the Cursor. A managed Cursor handles all of the niceties, such as unloading itself when the activity pauses, and requerying itself when the activity restarts. You can ask an Activity to begin managing an unmanaged Cursor object for you by calling
.Activity.startManagingCursor()
The first argument to either
or query()
is the provider URI — the managedQuery()
CONTENT_URI
constant that identifies a particular ContentProvider and data set (see URIs earlier).
To restrict a query to just one record, you can append the _ID
value for that record to the URI — that is, place a string matching the ID as the last segment of the path part of the URI. For example, if the ID is 23, the URI would be:
content://. . . ./23
There are some helper methods, particularly
and ContentUris.withAppendedId()
, that make it easy to append an ID to a URI. Both are static methods that return a Uri object with the ID added. So, for example, if you were looking for record 23 in the database of people contacts, you might construct a query as follows:Uri.withAppendedPath()
import android.provider.Contacts.People;
import android.content.ContentUris;
import android.net.Uri;
import android.database.Cursor; // Use the ContentUris method to produce the base URI for the contact with _ID == 23.
Uri myPerson = ContentUris.withAppendedId(People.CONTENT_URI, 23); // Alternatively, use the Uri method to produce the base URI.
// It takes a string rather than an integer.
Uri myPerson = Uri.withAppendedPath(People.CONTENT_URI, "23"); // Then query for this specific record:
Cursor cur = managedQuery(myPerson, null, null, null, null);
The other arguments to the
and query()
methods delimit the query in more detail. They are:managedQuery()
- The names of the data columns that should be returned. A
null
value returns all columns. Otherwise, only columns that are listed by name are returned. All the content providers that come with the platform define constants for their columns. For example, theandroid.provider.Contacts.Phones
class defines constants for the names of the columns in the phone table illustrated earlier —_ID
,NUMBER
,NUMBER_KEY
,NAME
, and so on. A filter detailing which rows to return, formatted as an SQL
WHERE
clause (excluding theWHERE
itself). Anull
value returns all rows (unless the URI limits the query to a single record).Selection arguments.
A sorting order for the rows that are returned, formatted as an SQL
ORDER BY
clause (excluding theORDER BY
itself). Anull
value returns the records in the default order for the table, which may be unordered.
Let's look at an example query to retrieve a list of contact names and their primary phone numbers:
import android.provider.Contacts.People;
import android.database.Cursor; // Form an array specifying which columns to return.
String[] projection = new String[] {
People._ID,
People._COUNT,
People.NAME,
People.NUMBER
}; // Get the base URI for the People table in the Contacts content provider.
Uri contacts = People.CONTENT_URI; // Make the query.
Cursor managedCursor = managedQuery(contacts,
projection, // Which columns to return
null, // Which rows to return (all rows)
null, // Selection arguments (none)
// Put the results in ascending order by name
People.NAME + " ASC");
This query retrieves data from the People table of the Contacts content provider. It gets the name, primary phone number, and unique record ID for each contact. It also reports the number of records that are returned as the _COUNT
field of each record.
The constants for the names of the columns are defined in various interfaces — _ID
and _COUNT
in BaseColumns
, NAME
in PeopleColumns
, and NUMBER
inPhoneColumns
. The Contacts.People
class implements each of these interfaces, which is why the code example above could refer to them using just the class name.
What a query returns
A query returns a set of zero or more database records. The names of the columns, their default order, and their data types are specific to each content provider. But every provider has an _ID
column, which holds a unique numeric ID for each record. Every provider can also report the number of records returned as the _COUNT
column; its value is the same for all rows.
Here is an example result set for the query in the previous section:
_ID | _COUNT | NAME | NUMBER |
---|---|---|---|
44 | 3 | Alan Vain | 212 555 1234 |
13 | 3 | Bully Pulpit | 425 555 6677 |
53 | 3 | Rex Cars | 201 555 4433 |
The retrieved data is exposed by a Cursor
object that can be used to iterate backward or forward through the result set. You can use this object only to read the data. To add, modify, or delete data, you must use a ContentResolver object.
Reading retrieved data
The Cursor object returned by a query provides access to a recordset of results. If you have queried for a specific record by ID, this set will contain only one value. Otherwise, it can contain multiple values. (If there are no matches, it can also be empty.) You can read data from specific fields in the record, but you must know the data type of the field, because the Cursor object has a separate method for reading each type of data — such as
,getString()
, and getInt()
. (However, for most types, if you call the method for reading strings, the Cursor object will give you the String representation of the data.) The Cursor lets you request the column name from the index of the column, or the index number from the column name.getFloat()
The following snippet demonstrates reading names and phone numbers from the query illustrated earlier:
import android.provider.Contacts.People; private void getColumnData(Cursor cur){
if (cur.moveToFirst()) { String name;
String phoneNumber;
int nameColumn = cur.getColumnIndex(People.NAME);
int phoneColumn = cur.getColumnIndex(People.NUMBER);
String imagePath;
do {
// Get the field values
name = cur.getString(nameColumn);
phoneNumber = cur.getString(phoneColumn);
// Do something with the values.
... } while (cur.moveToNext()); }
}
If a query can return binary data, such as an image or sound, the data may be directly entered in the table or the table entry for that data may be a string specifying a content:
URI that you can use to get the data. In general, smaller amounts of data (say, from 20 to 50K or less) are most often directly entered in the table and can be read by calling
. It returns a byte array.Cursor.getBlob()
If the table entry is a content:
URI, you should never try to open and read the file directly (for one thing, permissions problems can make this fail). Instead, you should call
to get an ContentResolver.openInputStream()
InputStream
object that you can use to read the data.
Modifying Data
Data kept by a content provider can be modified by:
- Adding new records
- Adding new values to existing records
- Batch updating existing records
- Deleting records
All data modification is accomplished using ContentResolver
methods. Some content providers require a more restrictive permission for writing data than they do for reading it. If you don't have permission to write to a content provider, the ContentResolver methods will fail.
Adding records
To add a new record to a content provider, first set up a map of key-value pairs in a ContentValues
object, where each key matches the name of a column in the content provider and the value is the desired value for the new record in that column. Then call
and pass it the URI of the provider and the ContentValues map. This method returns the full URI of the new record — that is, the provider's URI with the appended ID for the new record. You can then use this URI to query and get a Cursor over the new record, and to further modify the record. Here's an example:ContentResolver.insert()
import android.provider.Contacts.People;
import android.content.ContentResolver;
import android.content.ContentValues; ContentValues values = new ContentValues(); // Add Abraham Lincoln to contacts and make him a favorite.
values.put(People.NAME, "Abraham Lincoln");
// 1 = the new contact is added to favorites
// 0 = the new contact is not added to favorites
values.put(People.STARRED, 1); Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
Adding new values
Once a record exists, you can add new information to it or modify existing information. For example, the next step in the example above would be to add contact information — like a phone number or an IM or e-mail address — to the new entry.
The best way to add to a record in the Contacts database is to append the name of the table where the new data goes to the URI for the record, then use the amended URI to add the new data values. Each Contacts table exposes a name for this purpose as a CONTENT_DIRECTORY
constant. The following code continues the previous example by adding a phone number and e-mail address for the record just created:
Uri phoneUri = null;
Uri emailUri = null; // Add a phone number for Abraham Lincoln. Begin with the URI for
// the new record just returned by insert(); it ends with the _ID
// of the new record, so we don't have to add the ID ourselves.
// Then append the designation for the phone table to this URI,
// and use the resulting URI to insert the phone number.
phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY); values.clear();
values.put(People.Phones.TYPE, People.Phones.TYPE_MOBILE);
values.put(People.Phones.NUMBER, "1233214567");
getContentResolver().insert(phoneUri, values); // Now add an email address in the same way.
emailUri = Uri.withAppendedPath(uri, People.ContactMethods.CONTENT_DIRECTORY); values.clear();
// ContactMethods.KIND is used to distinguish different kinds of
// contact methods, such as email, IM, etc.
values.put(People.ContactMethods.KIND, Contacts.KIND_EMAIL);
values.put(People.ContactMethods.DATA, "test@example.com");
values.put(People.ContactMethods.TYPE, People.ContactMethods.TYPE_HOME);
getContentResolver().insert(emailUri, values);
You can place small amounts of binary data into a table by calling the version of
that takes a byte array. That would work for a small icon-like image or a short audio clip, for example. However, if you have a large amount of binary data to add, such as a photograph or a complete song, put a ContentValues.put()
content:
URI for the data in the table and call
with the file's URI. (That causes the content provider to store the data in a file and record the file path in a hidden field of the record.)ContentResolver.openOutputStream()
In this regard, the MediaStore
content provider, the main provider that dispenses image, audio, and video data, employs a special convention: The same URI that is used with query()
or managedQuery()
to get meta-information about the binary data (such as, the caption of a photograph or the date it was taken) is used with openInputStream()
to get the data itself. Similarly, the same URI that is used with insert()
to put meta-information into a MediaStore record is used with openOutputStream()
to place the binary data there. The following code snippet illustrates this convention:
import android.provider.MediaStore.Images.Media;
import android.content.ContentValues;
import java.io.OutputStream; // Save the name and description of an image in a ContentValues map.
ContentValues values = new ContentValues(3);
values.put(Media.DISPLAY_NAME, "road_trip_1");
values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
values.put(Media.MIME_TYPE, "image/jpeg"); // Add a new record without the bitmap, but with the values just set.
// insert() returns the URI of the new record.
Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values); // Now get a handle to the file for that record, and save the data into it.
// Here, sourceBitmap is a Bitmap object representing the file to save to the database.
try {
OutputStream outStream = getContentResolver().openOutputStream(uri);
sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
outStream.close();
} catch (Exception e) {
Log.e(TAG, "exception while writing image", e);
}
Batch updating records
To batch update a group of records (for example, to change "NY" to "New York" in all fields), call the
method with the columns and values to change.ContentResolver.update()
Deleting a record
To delete a single record, call {
with the URI of a specific row.ContentResolver.delete()
To delete multiple rows, call
with the URI of the type of record to delete (for example,ContentResolver.delete()
android.provider.Contacts.People.CONTENT_URI
) and an SQL WHERE
clause defining which rows to delete. (Caution: Be sure to include a valid WHERE
clause if you're deleting a general type, or you risk deleting more records than you intended!).
Creating a Content Provider
To create a content provider, you must:
- Set up a system for storing the data. Most content providers store their data using Android's file storage methods or SQLite databases, but you can store your data any way you want. Android provides the
SQLiteOpenHelper
class to help you create a database andSQLiteDatabase
to manage it. Extend the
ContentProvider
class to provide access to the data.Declare the content provider in the manifest file for your application (AndroidManifest.xml).
The following sections have notes on the last two of these tasks.
Extending the ContentProvider class
You define a ContentProvider
subclass to expose your data to others using the conventions expected by ContentResolver and Cursor objects. Principally, this means implementing six abstract methods declared in the ContentProvider class:
query()
insert()
update()
delete()
getType()
onCreate()
The query()
method must return a Cursor
object that can iterate over the requested data. Cursor itself is an interface, but Android provides some ready-made Cursor objects that you can use. For example, SQLiteCursor
can iterate over data stored in an SQLite database. You get the Cursor object by calling any of the SQLiteDatabase
class's query()
methods. There are other Cursor implementations — such as MatrixCursor
— for data not stored in a database.
Because these ContentProvider methods can be called from various ContentResolver objects in different processes and threads, they must be implemented in a thread-safe manner.
As a courtesy, you might also want to call
to notify listeners when there are modifications to the data.ContentResolver.notifyChange()
Beyond defining the subclass itself, there are other steps you should take to simplify the work of clients and make the class more accessible:
- Define a
public static final
Uri
namedCONTENT_URI
. This is the string that represents the fullcontent:
URI that your content provider handles. You must define a unique string for this value. The best solution is to use the fully-qualified class name of the content provider (made lowercase). So, for example, the URI for a TransportationProvider class could be defined as follows:public static final Uri CONTENT_URI =
Uri.parse("content://com.example.codelab.transportationprovider");If the provider has subtables, also define
CONTENT_URI
constants for each of the subtables. These URIs should all have the same authority (since that identifies the content provider), and be distinguished only by their paths. For example:content://com.example.codelab.transportationprovider/train
content://com.example.codelab.transportationprovider/air/domestic
content://com.example.codelab.transportationprovider/air/international
For an overview of
content:
URIs, see the Content URI Summary at the end of this document. Define the column names that the content provider will return to clients. If you are using an underlying database, these column names are typically identical to the SQL database column names they represent. Also define
public static
String constants that clients can use to specify the columns in queries and other instructions.Be sure to include an integer column named "
_id
" (with the constant_ID
) for the IDs of the records. You should have this field whether or not you have another field (such as a URL) that is also unique among all records. If you're using the SQLite database, the_ID
field should be the following type:INTEGER PRIMARY KEY AUTOINCREMENT
The
AUTOINCREMENT
descriptor is optional. But without it, SQLite increments an ID counter field to the next number above the largest existing number in the column. If you delete the last row, the next row added will have the same ID as the deleted row.AUTOINCREMENT
avoids this by having SQLite increment to the next largest value whether deleted or not.Carefully document the data type of each column. Clients need this information to read the data.
If you are handling a new data type, you must define a new MIME type to return in your implementation of
. The type depends in part on whether or not theContentProvider.getType()
content:
URI submitted togetType()
limits the request to a specific record. There's one form of the MIME type for a single record and another for multiple records. Use theUri
methods to help determine what is being requested. Here is the general format for each type:For a single record:
vnd.android.cursor.item/vnd.yourcompanyname.contenttype
For example, a request for train record 122, like this URI,
content://com.example.transportationprovider/trains/122
might return this MIME type:
vnd.android.cursor.item/vnd.example.rail
For multiple records:
vnd.android.cursor.dir/vnd.yourcompanyname.contenttype
For example, a request for all train records, like the following URI,
content://com.example.transportationprovider/trains
might return this MIME type:
vnd.android.cursor.dir/vnd.example.rail
If you are exposing byte data that's too big to put in the table itself — such as a large bitmap file — the field that exposes the data to clients should actually contain a
content:
URI string. This is the field that gives clients access to the data file. The record should also have another field, named "_data
" that lists the exact file path on the device for that file. This field is not intended to be read by the client, but by the ContentResolver. The client will call
on the user-facing field holding the URI for the item. The ContentResolver will request the "ContentResolver.openInputStream()
_data
" field for that record, and because it has higher permissions than a client, it should be able to access that file directly and return a read wrapper for the file to the client.
For an example of a private content provider implementation, see the NodePadProvider class in the Notepad sample application that ships with the SDK.
Declaring the content provider
To let the Android system know about the content provider you've developed, declare it with a <provider>
element in the application's AndroidManifest.xml file. Content providers that are not declared in the manifest are not visible to the Android system
The name
attribute is the fully qualified name of the ContentProvider subclass. The authorities
attribute is the authority part of the content:
URI that identifies the provider. For example if the ContentProvider subclass is AutoInfoProvider, the <provider>
element might look like this:
<provider android:name="com.example.autos.AutoInfoProvider"
android:authorities="com.example.autos.autoinfoprovider"
. . . />
</provider>
Note that the authorities
attribute omits the path part of a content:
URI. For example, if AutoInfoProvider controlled subtables for different types of autos or different manufacturers,
content://com.example.autos.autoinfoprovider/honda
content://com.example.autos.autoinfoprovider/gm/compact
content://com.example.autos.autoinfoprovider/gm/suv
those paths would not be declared in the manifest. The authority is what identifies the provider, not the path; your provider can interpret the path part of the URI in any way you choose.
Other <provider>
attributes can set permissions to read and write data, provide for an icon and text that can be displayed to users, enable and disable the provider, and so on. Set the multiprocess
attribute to "true
" if data does not need to be synchronized between multiple running versions of the content provider. This permits an instance of the provider to be created in each client process, eliminating the need to perform IPC.
Content URI Summary
Here is a recap of the important parts of a content URI:
- Standard prefix indicating that the data is controlled by a content provider. It's never modified.
The authority part of the URI; it identifies the content provider. For third-party applications, this should be a fully-qualified class name (reduced to lowercase) to ensure uniqueness. The authority is declared in the
<provider>
element'sauthorities
attribute:<provider android:name=".TransportationProvider"
android:authorities="com.example.transportationprovider"
. . . >The path that the content provider uses to determine what kind of data is being requested. This can be zero or more segments long. If the content provider exposes only one type of data (only trains, for example), it can be absent. If the provider exposes several types, including subtypes, it can be several segments long — for example, "
land/bus
", "land/train
", "sea/ship
", and "sea/submarine
" to give four possibilities.The ID of the specific record being requested, if any. This is the
_ID
value of the requested record. If the request is not limited to a single record, this segment and the trailing slash are omitted:content://com.example.transportationprovider/trains
Content Providers的步骤,来自官网文档的更多相关文章
- Unity shader 官网文档全方位学习(一)
转载:https://my.oschina.net/u/138823/blog/181131 摘要: 这篇文章主要介绍Surface Shaders基础及Examples详尽解析 What?? Sha ...
- Spring Security 官网文档学习
文章目录 通过`maven`向普通的`WEB`项目中引入`spring security` 配置 `spring security` `configure(HttpSecurity)` 方法 自定义U ...
- 部署openstack的官网文档解读mysql的配置文件
部署openstack的官网文档解读mysql的配置文件(使用与ubutu和centos7等系统) author:headsen chen 2017-10-12 16:57:11 个人原创,严禁转载 ...
- redis过期机制(官网文档总结)
官网地址:https://redis.io/commands/expire redis过期定义如下: Set a timeout on key. After the timeout has expir ...
- Hortonworks官网文档怎么找?
Hortonworks官网文档怎么找? 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 俗话说,授人予鱼不如授人予渔,网上部署HDP的部署方式的博客有很多,看得你是眼花缭乱的.其实万 ...
- 【VR】Leap Motion 官网文档 FingerModel (手指模型)
前言: 感谢关注和支持这个Leap Motion系列翻译的朋友们,非常抱歉因为工作原因非常久没有更新,今后这个翻译还会继续(除非官方直接给出中文文档).本篇献给大家的是 <FingerModel ...
- mybatis官网文档mybatis_doc
在平时的学习中,我们可以去参考官网的文档来学习,这个文档有中文的,方便我们去阅读,而且这里的分类很详细. 官网文档链接:http://www.mybatis.org/mybatis-3/zh/inde ...
- 你会阅读appium官网文档吗
高效学习appium第一步,学会查看appium官方文档.如果能把appium文档都通读一遍,对学习appium大有益处. 而能做到通读appium官方文档的人,想必不是很多,刚开始学习appium的 ...
- git研究详解(官网文档)及总结
前言:git作为新一代的版本控制软件,说实话比svn好用多了,个人见解,关于git的详细介绍及研究,我推荐三个地方 1.git官网上的文档(推荐UC浏览器,比火狐多个英文翻译的功能) 地址为:http ...
随机推荐
- python函数callable
callable(object) 中文说明:检查对象object是否可调用.如果返回True,object仍然可能调用失败:但如果返回False,调用对象ojbect绝对不会成功. 注意:类或函数是可 ...
- ActionBarSherlock学习笔记 第一篇——部署
ActionBarSherlock学习笔记 第一篇--部署 ActionBarSherlock是JakeWharton编写的一个开源框架,使用这个框架,可以实现在所有的Android ...
- HDU 1348 Wall
题解:计算凸包周长 #include <iostream> #include <cmath> #include <algorithm> const int size ...
- HDU 3756 Dome of Circus
不会做,参见别人的程序: /* 底面为xy平面和轴为z轴的圆锥,给定一些点,使得圆锥覆盖所有点并且体积最小 点都可以投射到xz平面,问题转换为确定一条直线(交x,z与正半轴)使得与x的截距r 和与z轴 ...
- Special Subsequence(离散化线段树+dp)
Special Subsequence Time Limit: 5 Seconds Memory Limit: 32768 KB There a sequence S with n inte ...
- 数据科学家:神话 & 超能力持有者
一个打破神话的季节,正在降临. 我将坦诚地揭穿人们关于数据科学家所持有的惯有看法.在下文中,我将一个一个展示这些观点,宛如将一个又一个的玻璃瓶子摔碎在墙壁上一样. 关于数据 ...
- 最新VMware Workstation 10注册码,绝对可用!
最近公司要在solaris上测试产品,需要用到虚拟机,于是下载了最新的虚拟机VMware Workstation 10,并找到了破解码,与大家共享: VMware workstation 10破解序列 ...
- android 中文 api (72) —— BluetoothSocket[蓝牙]
前言 本章内容是 android.bluetooth.BluetoothSocket,为Android蓝牙部分的章节翻译.蓝牙通讯套接字,代表了与远端设备的连接点,使用socket本地程序可以通过 ...
- (待解决问题)nowrap在table和td都设置了宽度的时候仍然有效
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 操作数组的工具类Arrays
Java提供的Arrays类里包含一些static修饰的方法可以直接操作数组. int binarySearch(type[] a, type key)使用二分法查询key元素值在a数组中出现的索引, ...