android 点滴积累

1、android程序查�包含"*" "#"的��a�r出�e的解�Q�k法

代�a�e�`提示: E/AndroidRuntime(1145): Caused by: android.database.sqlite.SQLiteException: near "*": syntax error: , while compiling: SELECT numbertype, new, duration, _id, numberlabel, name, number, type, date FROM calls WHERE (number = **9) ORDER BY date desc  解�Q:    	strQuery = "number = " + strQueryNumber; 			callLogCursor = TApplication.nowTApplication.getContentResolver() 					.query(CallLog.Calls.CONTENT_URI, null, strQuery, null, 							"date desc"); 							 							查�代�a改成: 							 								strQuery = "number = " + "'strQueryNumber'"; 			callLogCursor = TApplication.nowTApplication.getContentResolver() 					.query(CallLog.Calls.CONTENT_URI, null, strQuery, null, 							"date desc"); 							 	��Y:因��"*"�����炖锏年P�I字(未��C��),所有查找是���笳Z法�e�`,只需要拼接字符串,把"*"改成非�P�I字即可

2、 android通过查询电话号码获取联系人头像

// 取得Intent中的�^像 			ivShowImage = (ImageView) findViewById(R.id.call_log_detail_contact_img); 			//通话电话号码获取头像uri 			Uri uriNumber2Contacts = Uri 					.parse("content://com.android.contacts/" 							+ "data/phones/filter/" + strPhoneNumber); 			Cursor cursorCantacts = SApplication.nowSApplication 					.getContentResolver().query(uriNumber2Contacts, null, null, 							null, null); 			if (cursorCantacts.getCount() > 0) {	//若游标不为0则说明有头像,游标指向第一条记录 				cursorCantacts.moveToFirst(); 				Long contactID = cursorCantacts.getLong(cursorCantacts 						.getColumnIndex("contact_id")); 				Uri uri = ContentUris.withAppendedId( 						ContactsContract.Contacts.CONTENT_URI, contactID); 				InputStream input = ContactsContract.Contacts 						.openContactPhotoInputStream( 								SApplication.nowSApplication 										.getContentResolver(), uri); 				btContactImage = BitmapFactory.decodeStream(input); 				Log.i("info", "bt======" + btContactImage); 				ivShowImage.setImageBitmap(btContactImage);  			} else {//么有头像设置默认头像 				ivShowImage 						.setImageResource(R.drawable.call_log_contact_image2);  			} 		


/**
* @author 张兴业
* 邮箱:xy-zhang#163.com
* android开发进阶群:278401545
*
*/

你可能感兴趣的:(android,Date,image,null,input,电话)