calllog and callitem

fanfalveto

Active Member
Licensed User
Longtime User
I see calllog and callitem in phone library.But is possible delete the calllog?
Thank you.
 

corsaro

Member
Licensed User
Longtime User
googling, I have found this code to delete call logs. How can I write a similar one on b4a ?

Thanks in advance for helping me.

B4X:
try {
    String strNumberOne[] = {number};
    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));                            
            getContentResolver().delete(Uri.withAppendedPath(CallLog.Calls.CONTENT_URI, String.valueOf(idOfRowToDelete)), "", null);
        } while (cursor.moveToNext());
    }
} catch (Exception ex) {
    System.out.print("Exception here ");
}
 
Last edited:
Upvote 0

corsaro

Member
Licensed User
Longtime User
Upvote 0

corsaro

Member
Licensed User
Longtime User
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
 
Last edited:
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
make it ba.context.getContentResolver and pass ba as a parameter to the method (it will be invisible).

Like:
B4X:
public static boolean SaveSMS(BA ba, String filepath)
  {

   Cursor cursor1 = ba.context.getContentResolver().query(mSmsinboxQueryUri, new String[] { "_id", "thread_id", "address", "person", "date", "body", "type" }, null, null, null);
}
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
When I generate the javadoc, on the folder I have just 1 file: MyFirstLib.xml
I have not the jar file.

Every suggestion is appreciated.
regards

You must select from menu and then export file,You will have jar file

I' m sorry ,I forget to see all
 
Last edited:
Upvote 0

corsaro

Member
Licensed User
Longtime User
hey, i am also looking for delete a callitem from calllog , can you please share your lib ?

thank you very much

enjoy it

usage is very simple.

B4X:
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
 

Attachments

  • MyFirstLib.zip
    1.7 KB · Views: 350
Last edited:
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
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:
 
Upvote 0

omidaghakhani1368

Well-Known Member
Licensed User
Longtime User
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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top