//試試這個REQ
public void deleteAllCalendar(){
Log.i(TAG, "In deleteAllCalendar()");
String strUriEvents = "content://calendar/events";
Uri uri_calendar = Uri.parse(strUriEvents);
String str_column_name = "_id";
String[] projection = {str_column_name};
int columnIndex = 0;
String str_id = "";
Vector<String> vector_id = new Vector<String>();
int delRow = 0;
String where = "";
try {
Cursor cursor = cr.query(uri_calendar, projection, null, null, null);
if(cursor.moveToFirst()){
do{
columnIndex = cursor.getColumnIndex(str_column_name);
str_id = cursor.getString(columnIndex);
vector_id.add(str_id);
}while(cursor.moveToNext());
}
cursor.close();
for(int i=0; i<vector_id.size(); i++){
str_id = vector_id.get(i);
where = str_column_name+"="+str_id;
delRow = cr.delete(uri_calendar, where, null);
Log.i(TAG, "deleteAllCalendar(),delRow:"+delRow);
}
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(TAG, "deleteAllCalendar(),Exception");
e.printStackTrace();
}
Log.i(TAG, "Out deleteAllCalendar()");
}
什麼是有針對性的API級別? (在API級別14/Android 4.0之前,日曆API沒有標準化)。 – Stefan
目標api是api等級8及以上。 –