Contacts Module example
Contacts Example
from appuifw import *
from telephone import *
import contacts
old_body=app.body
db=contacts.open()
entry =db.find(query(u'Insert name','text'))
L=[]
for item in entry:
L.append(item.title)
if len(L)>0:
index = appuifw.selection_list(choices=L , search_field=0)
num=entry[index].find('mobile_number')[0].value
dial(num)
else:
note(u'No matches','error')
app.body=old_body
app.set_exit()
Get Number of the SMS Sender
import contacts #import contact db
db = contacts.open() #store in a variable "db"
def getSenderNum(sms_sender):
found = db.find(sms_sender) #find in database the contact name
try: found #check if found
except NameError:
senderData = found[0]
senderNum = senderData.find("mobile_number")[0].value
else:
senderNum = sms_sender
return senderNum
#now all you have to do is assign a variable the number of that contact name
mobileNum = getSenderNum(contactName)
#change contactName to whatever variable you stored your ripped contact