private void saveSteps(int step) {
Cursor cursor = getContentResolver().query(Downloads.CONTENT_URI,
new String[]{Downloads._ID, Downloads.COLUMN_VID, Downloads.COLUMN_STATUS, Downloads._DATA},
getQueryWhere(),
null,
null);
if (null == cursor)
return;
if (cursor.moveToNext()) {
int status = cursor.getInt(cursor.getColumnIndexOrThrow(Downloads.COLUMN_STATUS));
if (step != status) {
ContentValues values = new ContentValues();
values.put(Downloads.COLUMN_STATUS, step);
int id = cursor.getInt(cursor.getColumnIndexOrThrow(Downloads._ID));
getContentResolver().update(ContentUris.withAppendedId(Downloads.CONTENT_URI, id), values, null, null);
String filePath = cursor.getString(cursor.getColumnIndexOrThrow(Downloads._DATA));
File file = new File(filePath);
if (file.exists())
file.delete();
//xlh_add 删除数据库中本条数据
getContentResolver().delete(ContentUris.withAppendedId(Downloads.CONTENT_URI, id), "(" + Downloads.COLUMN_VID + " = ' " + appDetail.getAppID() + "')", null);
}private String getQueryWhere() {
// String w="(" + Downloads.COLUMN_VID + " = ' " + appDetail.getAppID() + "')";
return "(" + Downloads.COLUMN_VID + " = ' " + appDetail.getAppID() + "') AND (" + Downloads.COLUMN_STATUS + " <= '200')";
Cursor c = getContentResolver.query(Message.Content_URI ,
new String[]{SyncColumns.Server_Id} , SyncColumns.Id+"=?" , new String[]{Long.toString(MessageId)} , null);
Cursor c = getContentResolver.query(Message.Content_URI ,
new String[]{SyncColumns.Server_Id} , "("+SyncColumns.Id+"=' "+Long.toString(MessageId)+ " ')" ,null, null);
ContentValues cv = new ContentValues();
cv.put(Body.HTML_Content, newHtmlBody);//第一个参数是列名,第二个参数是要放入的值
String where = Body.Message_Key + "=" + mMessageId;
getContentResolver().update(uri , cv , where , null);
//这里的四个参数应该很清楚了,uri是表,cv上面要更新的值,where是搜索行的语句,null是历史记录可以为空