lundi 29 février 2016

cant delete from getContentResolver

i cant delete a conversation from getContentResolver , i dont know in which part am getting mistakes , as i also searched about these but cant help my self and thanks alot in advance here is the code

    public static boolean deleteSmsofContact(Context context, String number,
        boolean deleteLocked)
{
    int result;

    if (deleteLocked) {

       //changes values

        String[] selectionArgs=new String[]{number};
        String selection= ""+"address=?";

        //
        result = context.getContentResolver().delete(Uri.parse("content://sms/"),selection,selectionArgs);
     // Log.d("UF","WOW "+result+" " +number);
    } else {
        result = context.getContentResolver().delete(Constants.URI_SMS,
                "address=? AND locked=?", new String[] { number, "1" });
    }

    if (result > 0) {
        return true;
    }

    return false;
}

here is the method from which i am calling

  boolean result = Utils.deleteSmsofContact(InboxActivity.this, sms.getNumber(), true);
                                            if (result) {
                                                dataList.remove(threadPosition);
                                                iAdapter.notifyDataSetChanged();
                                                Toast.makeText(InboxActivity.this,"Removed",Toast.LENGTH_LONG).show();
                                            }else
                                            {
                                                Toast.makeText(InboxActivity.this,"cant removed",Toast.LENGTH_LONG).show();
                                            }

Aucun commentaire:

Enregistrer un commentaire