delete all sms

fanfalveto

Active Member
Licensed User
Longtime User
i try doing that
B4X:
Dim aa As SmsMessages
Dim lista As List
Dim lista2 As List
Dim i As Int
lista.Initialize
lista=aa.GetAll
For i=0 To lista.Size-1
lista2=aa.GetByPersonId(i)
 aa.deletesms(lista2.Get(i))
Next
don´t work.
Anyone have any idea?
thank you
 

mc73

Well-Known Member
Licensed User
Longtime User
I know nothing about the lib used but there is a problem in your code. You should handle the members of list2 by looping through its contents again:
B4X:
 for j=0 to lista2size-2
aa.deletesms(lista2.get(j))
'I am not sure for the above, since I don't know the function used
next 'j
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Look for SmsPlus library, it works fine for deleting sms. It seems it is not possible with the standard library.
Marco
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Ok, try this with smsplus lib:

B4X:
        Dim a As SmsMessages
   Dim list1 As List
   Dim aa, Id As String
   Dim sta, sto As Int
   list1=a.GetAll()
   
   If list1.Size=0 Then Return
   
   For i = list1.Size-1 To 0 Step -1
      DoEvents
      aa=list1.Get(i)
      sta=aa.IndexOf("Body=")+5
      sto=aa.IndexOf(", Address=")
      Id=aa.SubString2(sta,sto)
      Delete_Sms(Id)
        next
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
Ok marcick,your code runs,only can change the string "sta",this is finally the code
B4X:
       Dim mensajes As SmsMessages
Dim list1 As List
Dim aa, Id As String
Dim sta, sto As Int
list1=mensajes.GetAll()
If list1.Size=0 Then Return
For i = list1.Size-1 To 0 Step -1
DoEvents
aa=list1.Get(i)
sta=aa.IndexOf("Id=")+3
sto=aa.IndexOf(", ThreadId=")
Id=aa.SubString2(sta,sto)
mensajes.deletesms(Id)
Next
Thank you
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
ah, yes, sorry, I copied the wrong piece. That sta and sto are for getting the body, not the id, as you saw ...
Marco
 
Upvote 0
Top