After reading some tutorials about eclipse (b4a is better then eclipse , and after making a small change in original code, I found this code on eclipse works, and deletes last log in calllogs on my galaxy ACE 2.3.5, for a specific number in call logs.
B4X:
try {
Toast.makeText(getApplicationContext(), "eseguito", Toast.LENGTH_SHORT).show();
String strNumberOne[] = { "+44numbertodelete" };
Cursor cursor = getContentResolver().query(CallLog.Calls.CONTENT_URI, null, CallLog.Calls.NUMBER + " = ? ", strNumberOne, "");
boolean bol = cursor.moveToFirst();
if (bol) {
do {
int idOfRowToDelete = cursor.getInt(cursor.getColumnIndex(CallLog.Calls._ID));
this.getContentResolver().delete(CallLog.Calls.CONTENT_URI,String.valueOf(idOfRowToDelete),null); // this line works and deletes the log
} while (cursor.moveToNext());
}
} catch (Exception ex) {
Toast.makeText(getApplicationContext(), "non eseguito", Toast.LENGTH_SHORT).show();
System.out.print("Exception here ");
}
}
}
But when trying to make a library for B4A, following exactly your tutorial, when I write the code, eclipse tells me there is an error:
the methot getContentResolver() is undefinied for the type MyFirsLib.
Can someone with more experience then me ( I use B4A by 4 days, and eclipse by 1 day) help me to make this small library?
Thanks in advance
Sub Process_Globals
Dim mfl As MyFirstLib
End Sub
Sub Button1_Click
mfl.deletecalllogs("+440000000000") ' where +44000000000 is a string with the number to be deleted from calllogs
End Sub
with this you can delete all callog items using MyFisrtLib
B4X:
Dim reg As MyFirstLib
Dim sta,aa,sto,num As String
Dim aaa As CallLog
Dim ll As List
ll=aaa.GetAll(0)
For i =0 To ll.Size-1
aa=ll.Get(i)
sta=aa.IndexOf("Number=")+7
sto=aa.IndexOf(",CachedName=")
num=aa.SubString2(sta,sto)
If num<>"" Then
try
reg.DeleteCallLogs(num)
catch
end try
End If
Next
Log("fin")
if calllog log list is so big you must wait for a long time.Thank you for this libray :sign0098:
Hi.
I use referer library for delete calllog but not deleted.
example when i dial *0* and then run activity for delete it but not delete and not get error