public Uri insert(Uri uri, ContentValues values) {
switch(MATCHER.match(uri)) {
case TB:
ContentValues v2 = new ContentValues(values);
// 判断是否存在该值
if(!v2.containsKey(table.KEY_NAME)) {
values.put(table.KEY_NAME, "def_name");
}
if(!v2.containsKey(table.KEY_NUM)) {
values.put(table.KEY_NUM, "def_num");
}
SQLiteDatabase db = databaseHelper.getWritableDatabase();
// 返回行ID 红色的地方写的内容有什么限制为什么?
--------------------------------------------------------------------------------
long rowId = db.insert(databaseHelper.DB_TABLE, table.KEY_NAME,
values);
--------------------------------------------------------------------------------
Log.e("cp", "rowid " + rowId);
if(rowId > 0) {
// 生成一个URI content://d.m.dbname/tb/1
Uri noteUri = ContentUris.withAppendedId(
Uri.parse("content://" + table.AUTHORITY + "/tb"),
rowId);
getContext().getContentResolver().notifyChange(noteUri,
null);
return noteUri;
}
break;
}
return null;
} @Override
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
switch(MATCHER.match(uri)) {
case TB:
qb.setTables(DatabaseHelper.DB_TABLE);
qb.setProjectionMap(projectMap);
break;
case TB_ID: break;
}
SQLiteDatabase db = databaseHelper.getReadableDatabase();
Cursor c = qb.query(db, projection, selection, selectionArgs, null,
null, sortOrder);
--------------------------------------------------------------------------------
//这句的作用是什么?
c.setNotificationUri(getContext().getContentResolver(), uri);
--------------------------------------------------------------------------------
return c;
}MIME类型
怎么自定义类型?
写法有什么规定?在增删改中都有
getContext().getContentResolver().notifyChange(noteUri,null);
有什么用我还有两个帖子没结
http://topic.csdn.net/u/20120703/09/34f730ae-d33d-4111-acc9-6a9dfcab92a5.html
http://topic.csdn.net/u/20120710/10/802d833a-f94d-40f1-9c39-d28663c92258.html
解决方案 »
- 安卓播放器:把主题存好,运行的时候继续是上次存的主题,但出现错误了
- 联系人号码的自定义标签问题
- ((ViewGroup)findViewById(android.R.id.content)).getChildAt(0)是什么类型的?
- 图表中鼠标点击显示数据的问题
- HeapWorker may be wedged 问题
- 管理员请进------
- 这段代码加了try catch,有没有意义?
- 有关蓝牙BLE获取不到特征值的问题
- 这样用HttpURLConnection哪里出错了?
- listview通过滚动摆脱底部button遮盖的问题
- list滚动时出现黑色底的问题
- 申请android google map api key 无法打开网页
2. notifyChange,这个是用来通知注册了ContentObserver的程序,数据库内容发生了变化。说白了,就是用来给监听数据库的程序发一个通知
<intent-filter>
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
</intent-filter>
<intent-filter>
<data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
</intent-filter>
这是什么意思有什么作用?
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///mnt/sdcard/11.mp3");
i.setDataAndType(uri, "audio/mpeg");
http://download.csdn.net/detail/long33long/4415566
这个本书中讲的很清楚的
我不管了
求大神写个MIME的Demo
注释多一点 内容详细一点img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]img=http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/3.gif][/img]