活动介绍
file-type

ContentUris详解与3G移动通信技术概览

PPT文件

下载需积分: 50 | 1.56MB | 更新于2024-07-10 | 109 浏览量 | 2 下载量 举报 收藏
download 立即下载
"本文主要介绍了ContentUris类在Android中的使用,以及3G技术与智能手机软件平台,特别是Android操作系统的基本概念。" ContentUris类在Android中的应用是处理与内容提供者(Content Provider)相关的URI操作。它允许开发者方便地添加或解析包含ID信息的URI。在Android中,内容提供者是数据共享的一种机制,它可以使得应用程序之间能够安全地访问彼此的数据。ContentUris类提供了两个关键方法: 1. `withAppendedId(uri, id)`:此方法用于在给定的URI后面添加一个ID,形成新的URI。例如,如果你有一个基础URI "content://cn.itcast.provider.personprovider/person",你可以通过调用`withAppendedId(uri, 10)`得到一个包含特定ID的URI:"content://cn.itcast.provider.personprovider/person/10"。这在你需要访问某个特定记录时非常有用。 2. `parseId(uri)`:此方法用于从一个包含ID的URI中提取出ID部分。例如,给定URI "content://cn.itcast.provider.personprovider/person/10",`parseId(uri)`会返回10,这是URI中表示特定记录的ID。 3G技术是第三代移动通信标准,它将无线通信与国际互联网等多媒体通信结合,支持高速数据传输。3G的三大主要标准分别是WCDMA(中国联通)、CDMA2000(中国电信)和TD-SCDMA(中国移动)。这些标准提高了语音和数据的传输速度,使得多媒体服务如视频通话、高速上网和流媒体成为可能。2.5G是2G到3G的过渡阶段,如GPRS和CDMA2000 1X,它们提供了比2G更高的数据速率,但未达到3G的水平。 智能手机软件平台多样,包括Symbian、Windows Mobile、RIM BlackBerry、Android、iPhone和Java/J2ME。其中,Android是由Google推出的开源操作系统,基于Linux内核,采用了软件堆层架构,由操作系统、中间件和应用程序三部分组成。Android的开放性使其在2009年的市场份额逐渐增长,特别是在开发者社区中广受欢迎,因为它提供了丰富的API和灵活的定制能力。 总结来说,ContentUris类是Android开发中处理内容提供者URI的重要工具,而3G和智能手机软件平台则反映了移动通信技术和市场的演进。理解这些知识点对进行Android应用开发至关重要,尤其是在设计和实现涉及数据共享和跨应用交互的应用程序时。

相关推荐

filetype

代码如下:package com.example.myapplication; import android.content.ContentProvider; import android.content.ContentUris; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.net.Uri; import android.util.Log; public class DatabaseProvider extends ContentProvider { // 授权标识 public static final String AUTHORITY = "com.example.myapplication.provider"; public static final Uri CONTENT_URI = Uri.parse("content://"+AUTHORITY+"/person"); public static final String COLUMN_ID = "id"; public static final String COLUMN_NAME = "name"; public static final String COLUMN_NUMBER = "number"; public static final String COLUMN_ISSTAR = "isstar"; private static int personDir=0;//列表 private static int personItem=1;//单条记录 // 初始化:创建UriMatcher对象,参数UriMatcher.NO_MATCH表示初始状态(无匹配)。 // 添加匹配规则:使用addURI方法,参数为授权(authority)、路径(path)和自定义代码(code)。 // 使用:通过match方法匹配传入的Uri,返回自定义代码,然后根据代码进行相应处理。 private static UriMatcher uriMatcher=new UriMatcher(UriMatcher.NO_MATCH);//初始状态没匹配到任何URI private SQLiteDatabase dbHelper; static {//只在类被加载时执行一次 uriMatcher.addURI(AUTHORITY, "person", personDir); // 整个表,匹配返回匹配吗personDir uriMatcher.addURI(AUTHORITY, "person/#", personItem); // 单条记录,#匹配由任意长度的数字字符组成的字符串 } //uri 映射至程序公开的数据表person //projection 是检索到的每个行所应包含的列的数组。 //selection 指定选择行的条件。 //sortOrder 指定在返回的 Cursor 中各行的显示顺序。 public DatabaseProvider() { } @Override public int delete(Uri uri, String selection, String[] selectionArgs) { // Implement this to handle requests to delete one or more rows. throw new UnsupportedOperationException("Not yet implemented"); } @Override public String getType(Uri uri) { // TODO: Implement this to handle requests for the MIME type of the data // at the given URI. throw new UnsupportedOperationException("Not yet implemented"); } @Override public Uri insert(Uri uri, ContentValues values) { // TODO: Implement this to handle requests to insert a new row. throw new UnsupportedOperationException("Not yet implemented"); } @Override public boolean onCreate() { // TODO: Implement this to initialize your content provider on startup. return false; } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { switch (uriMatcher.match(uri)){ case 0: Log.i("test","query所有"); return dbHelper.query(false,"person",projection,selection,selectionArgs,null,null,sortOrder,null); case 1: long id= ContentUris.parseId(uri); Log.i("test","query单个"); return dbHelper.rawQuery("select * from person where id=?",new String[]{id+""}); } return null; } @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { // TODO: Implement this to handle requests to update one or more rows. throw new UnsupportedOperationException("Not yet implemented"); } }

双联装三吋炮的娇喘
  • 粉丝: 23
上传资源 快速赚钱