hi,

i have achieved reading sms by following function though it is not recommend
by google.*But how can i read calendar events?*


*public* *static* *void* getAllSMS(Context context) {

*try* {

Uri SMSURI = Uri.*parse*("content://sms/");

String[] projection = *new* String[] { "_id", "address", "body",

"date" };

Cursor cursor = *null*;

*try* {

cursor = context.getContentResolver().query(SMSURI, projection,

*null* // selection

, *null* // selectionArgs

, *null*); // sortOrder

*if* (cursor != *null* && cursor.moveToFirst()) {

*do* {

*int* *id* = cursor.getInt(cursor.getColumnIndex("_id"));

String *address* = cursor.getString(cursor

.getColumnIndex("address"));

String *body* = cursor.getString(cursor

.getColumnIndex("body"));

String date = cursor.getString(cursor

.getColumnIndex("date"));

SimpleDateFormat formatter = *new* SimpleDateFormat(

"dd/MM/yyyy - HH:mm:ss");

date = formatter.format(*new* Date(Long.*parseLong*(date)));

} *while* (cursor.moveToNext());

}

} *catch* (Exception e) {

e.printStackTrace();

} *finally* {

*if* (cursor != *null*) {

cursor.close();

}

}

} *catch* (Exception e) {

e.printStackTrace();

}

}

-- 
Regards,
Hitendrasinh Gohil

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to