Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从blackberry中的数据库获取侦听器数据时出错_Blackberry_Ellipse - Fatal编程技术网

从blackberry中的数据库获取侦听器数据时出错

从blackberry中的数据库获取侦听器数据时出错,blackberry,ellipse,Blackberry,Ellipse,过去三天我一直在尝试,但我没能解决这个问题;编辑表和查询 我一直在使用perstlite来存储数据;我已经为所需的类创建了表和查询 现在我一直在手机上收听联系人,我只能在该类中获取数据,但我无法在主类中或项目中的任何位置获取信息,尽管我已经调用了该类。有人能帮我解决这个问题吗 这是我的节目 package com.Wblower.listeners; import java.util.Hashtable; import javax.microedition.pim.Contact; im

过去三天我一直在尝试,但我没能解决这个问题;编辑表和查询

我一直在使用perstlite来存储数据;我已经为所需的类创建了表和查询

现在我一直在手机上收听联系人,我只能在该类中获取数据,但我无法在主类中或项目中的任何位置获取信息,尽管我已经调用了该类。有人能帮我解决这个问题吗

这是我的节目

package com.Wblower.listeners;



import java.util.Hashtable;

import javax.microedition.pim.Contact;
import javax.microedition.pim.PIMItem;
import javax.microedition.pim.PIMList;
import com.Wblower.db.ContactlistdatabaseQueries;
import com.Wblower.db.Contactlistdatabasetable;
import com.Wblower.db.DataBaseConnectivity;
import com.Wblower.util.DateTimeUtil;



import net.rim.blackberry.api.pdap.BlackBerryContact;
import net.rim.blackberry.api.pdap.BlackBerryContactList;
import net.rim.blackberry.api.pdap.PIMListListener;

public class ContactListener implements PIMListListener {

    BlackBerryContactList contactList;
    DataBaseConnectivity dbconnectVity = new DataBaseConnectivity();

    public void itemAdded(PIMItem arg0) {

        System.out.println("Item Added ==");
        String firstname = "none";
        String lastname = "none";
        String mobile = "none";
        String mobile1 = "none";
        String mobile2 = "none";
        String email = "none";
        String email1 = "none";
        String web = "none";
        String company = "none";
        String address = "none";
        String address1 = "none";
        String name[] = { "" };
        String timeStamp = "none";

        PIMList contacts = arg0.getPIMList();
        Contact contact = (Contact) arg0;

        if (contacts.isSupportedField(Contact.NAME)) {

            try {
                if (contact.countValues(Contact.NAME) > 0)
                    name = contact.getStringArray(Contact.NAME, 0);
                if (name[Contact.NAME_GIVEN] != null)
                    firstname = name[Contact.NAME_GIVEN];
                System.out.println("FirstName= " + firstname);
                if (name[Contact.NAME_FAMILY] != null)
                    lastname = name[Contact.NAME_FAMILY];
                System.out.println("LastName= " + lastname);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }

        }
        if (contacts.isSupportedField(Contact.EMAIL)) {
            try {
                if (contact.countValues(Contact.EMAIL) > 0)
                    email = contact.getString(Contact.EMAIL, 0);
                System.out.println("Email " + email);

                if (contact.countValues(Contact.EMAIL) > 1)
                    email1 = contact.getString(Contact.EMAIL, 1);
                System.out.println("Email " + email1);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.ORG)) {

            try {
                if (contact.countValues(Contact.ORG) > 0)
                    company = contact.getString(Contact.ORG, 0);
                System.out.println("Company " + company);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.URL)) {
            try {
                if (contact.countValues(Contact.URL) > 0)
                    web = contact.getString(Contact.URL, 0);
                System.out.println("web " + web);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }
        if (contacts.isSupportedField(Contact.TEL)) {
            try {
                if (contact.countValues(Contact.TEL) > 0)
                    mobile = contact.getString(Contact.TEL, 0);
                System.out.println("Phone " + mobile);

                if (contact.countValues(Contact.TEL) > 1)
                    mobile1 = contact.getString(Contact.TEL, 1);
                System.out.println("Phone " + mobile1);

                if (contact.countValues(Contact.TEL) > 2)
                    mobile2 = contact.getString(Contact.TEL, 2);
                System.out.println("Phone " + mobile2);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
            if (contacts.isSupportedField(Contact.ADDR)) {

                try {
                    address = "";
                    String[] addressarr = contact.getStringArray(
                            BlackBerryContact.ADDR, 0);

                    for (int i = 0; i < addressarr.length; i++) {

                        if (addressarr[i] != null) {
                            address = address + " " + addressarr[i];

                        }

                    }
                    System.out.println("Address==" + address);

                    address1 = "";
                    String[] addressar = contact.getStringArray(
                            BlackBerryContact.ADDR, 1);

                    for (int i = 0; i < addressar.length; i++) {
                        if (addressar[i] != null) {
                            address1 = address1 + " " + addressar[i];

                        }

                    }
                    System.out.println("Address==" + address1);
                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                timeStamp = DateTimeUtil.timestamp();

                try {

                    System.out.println("Entering into the db");
                    dbconnectVity.setDataBase();
                    Contactlistdatabasetable Contactlist;
                    Contactlist = new Contactlistdatabasetable(
                            "Contacts", "Add", firstname, lastname, mobile,
                            mobile1, mobile2, email, email1, web, company,
                            address, address1, timeStamp);
                    ContactlistdatabaseQueries.insertSingleContactlist(Contactlist);
                    ContactlistdatabaseQueries.selectWholeContactlist();         
                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                return;

            }

        }

    }

    public void itemRemoved(PIMItem arg0) {
        System.out.println("Item Removed ==");
        String firstname = "none";
        String lastname = "none";
        String mobile = "none";
        String mobile1 = "none";
        String mobile2 = "none";
        String email = "none";
        String email1 = "none";
        String web = "none";
        String company = "none";
        String address = "none";
        String address1 = "none";
        String name[] = { "" };
        String timeStamp = "none";

        PIMList contacts = arg0.getPIMList();
        Contact contact = (Contact) arg0;

        if (contacts.isSupportedField(Contact.NAME)) {

            try {
                if (contact.countValues(Contact.NAME) > 0)
                    name = contact.getStringArray(Contact.NAME, 0);
                if (name[Contact.NAME_GIVEN] != null)
                    firstname = name[Contact.NAME_GIVEN];
                System.out.println("FirstName= " + firstname);
                if (name[Contact.NAME_FAMILY] != null)
                    lastname = name[Contact.NAME_FAMILY];
                System.out.println("LastName= " + lastname);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }

        }
        if (contacts.isSupportedField(Contact.EMAIL)) {
            try {
                if (contact.countValues(Contact.EMAIL) > 0)
                    email = contact.getString(Contact.EMAIL, 0);
                System.out.println("Email " + email);

                if (contact.countValues(Contact.EMAIL) > 1)
                    email1 = contact.getString(Contact.EMAIL, 1);
                System.out.println("Email " + email1);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.ORG)) {

            try {
                if (contact.countValues(Contact.ORG) > 0)
                    company = contact.getString(Contact.ORG, 0);
                System.out.println("Company " + company);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.URL)) {
            try {
                if (contact.countValues(Contact.URL) > 0)
                    web = contact.getString(Contact.URL, 0);
                System.out.println("web " + web);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }
        if (contacts.isSupportedField(Contact.TEL)) {
            try {
                if (contact.countValues(Contact.TEL) > 0)
                    mobile = contact.getString(Contact.TEL, 0);
                System.out.println("Phone " + mobile);

                if (contact.countValues(Contact.TEL) > 1)
                    mobile1 = contact.getString(Contact.TEL, 1);
                System.out.println("Phone " + mobile1);

                if (contact.countValues(Contact.TEL) > 2)
                    mobile2 = contact.getString(Contact.TEL, 2);
                System.out.println("Phone " + mobile2);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
            if (contacts.isSupportedField(Contact.ADDR)) {

                try {
                    address = "";
                    String[] addressarr = contact.getStringArray(
                            BlackBerryContact.ADDR, 0);

                    for (int i = 0; i < addressarr.length; i++) {

                        if (addressarr[i] != null) {
                            address = address + " " + addressarr[i];

                        }

                    }
                    System.out.println("Address==" + address);

                    address1 = "";
                    String[] addressar = contact.getStringArray(
                            BlackBerryContact.ADDR, 1);

                    for (int i = 0; i < addressar.length; i++) {

                        if (addressar[i] != null) {
                            address1 = address1 + " " + addressar[i];

                        }

                    }
                    System.out.println("Address==" + address1);
                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                timeStamp = DateTimeUtil.timestamp();

                try {
                    System.out.println("Entering into the db");
                    dbconnectVity.setDataBase();
                    Contactlistdatabasetable Contactlist;
                    Contactlist = new Contactlistdatabasetable(
                            "Contacts", "Delete", firstname, lastname, mobile,
                            mobile1, mobile2, email, email1, web, company,
                            address, address1, timeStamp);
                    ContactlistdatabaseQueries.insertSingleContactlist(Contactlist);
                    ContactlistdatabaseQueries.selectWholeContactlist();
                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                return;
            }
        }

    }

    public void itemUpdated(PIMItem arg0, PIMItem arg1) {
        System.out.println("Item Updated ==");
        String firstname = "none";
        String lastname = "none";
        String mobile = "none";
        String mobile1 = "none";
        String mobile2 = "none";
        String email = "none";
        String email1 = "none";
        String web = "none";
        String company = "none";
        String address = "none";
        String address1 = "none";
        String name[] = { "" };
        String timeStamp = "none";

        PIMList contacts = arg1.getPIMList();
        Contact contact = (Contact) arg1;

        if (contacts.isSupportedField(Contact.NAME)) {

            try {
                if (contact.countValues(Contact.NAME) > 0)
                    name = contact.getStringArray(Contact.NAME, 0);
                if (name[Contact.NAME_GIVEN] != null)
                    firstname = name[Contact.NAME_GIVEN];
                System.out.println("FirstName= " + firstname);
                if (name[Contact.NAME_FAMILY] != null)
                    lastname = name[Contact.NAME_FAMILY];
                System.out.println("LastName= " + lastname);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }

        }
        if (contacts.isSupportedField(Contact.EMAIL)) {
            try {
                if (contact.countValues(Contact.EMAIL) > 0)
                    email = contact.getString(Contact.EMAIL, 0);
                System.out.println("Email " + email);

                if (contact.countValues(Contact.EMAIL) > 1)
                    email1 = contact.getString(Contact.EMAIL, 1);
                System.out.println("Email " + email1);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.ORG)) {

            try {
                if (contact.countValues(Contact.ORG) > 0)
                    company = contact.getString(Contact.ORG, 0);
                System.out.println("Company " + company);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }

        if (contacts.isSupportedField(Contact.URL)) {
            try {
                if (contact.countValues(Contact.URL) > 0)
                    web = contact.getString(Contact.URL, 0);
                System.out.println("web " + web);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
        }
        if (contacts.isSupportedField(Contact.TEL)) {
            try {
                if (contact.countValues(Contact.TEL) > 0)
                    mobile = contact.getString(Contact.TEL, 0);
                System.out.println("Phone " + mobile);

                if (contact.countValues(Contact.TEL) > 1)
                    mobile1 = contact.getString(Contact.TEL, 1);
                System.out.println("Phone " + mobile1);

                if (contact.countValues(Contact.TEL) > 2)
                    mobile2 = contact.getString(Contact.TEL, 2);
                System.out.println("Phone " + mobile2);
            } catch (Exception e) {
                System.out.println("Exception::" + e.getMessage());
            }
            if (contacts.isSupportedField(Contact.ADDR)) {

                try {
                    address = "";
                    String[] addressarr = contact.getStringArray(
                            BlackBerryContact.ADDR, 0);

                    for (int i = 0; i < addressarr.length; i++) {

                        if (addressarr[i] != null) {
                            address = address + " " + addressarr[i];

                        }

                    }
                    System.out.println("Address==" + address);
                    address1 = "";
                    String[] addressar = contact.getStringArray(
                            BlackBerryContact.ADDR, 1);

                    for (int i = 0; i < addressar.length; i++) {
                        if (addressar[i] != null) {
                            address1 = address1 + " " + addressar[i];

                        }

                    }
                    System.out.println("Address==" + address1);
                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                timeStamp = DateTimeUtil.timestamp();

                try {
                    System.out.println("Entering into the db");
                    dbconnectVity.setDataBase();
                    Contactlistdatabasetable Contactlist;
                    Contactlist = new Contactlistdatabasetable(
                            "Contacts", "Update", firstname, lastname, mobile,
                            mobile1, mobile2, email, email1, web, company,
                            address, address1, timeStamp);
                    ContactlistdatabaseQueries.insertSingleContactlist(Contactlist);
                    ContactlistdatabaseQueries.selectWholeContactlist();

                } catch (Exception e) {
                    System.out.println("Exception::" + e.getMessage());
                }

                return;
            }
        }
    }
}
package com.Wblower.listeners;
导入java.util.Hashtable;
导入javax.microedition.pim.Contact;
导入javax.microedition.pim.pimiitem;
导入javax.microedition.pim.PIMList;
导入com.Wblower.db.ContactlistdatabaseQueries;
导入com.Wblower.db.Contactlistdatabasetable;
导入com.Wblower.db.DataBaseConnectivity;
导入com.Wblower.util.DateTimeUtil;
导入net.rim.blackberry.api.pdap.BlackBerryContact;
导入net.rim.blackberry.api.pdap.BlackBerryContactList;
导入net.rim.blackberry.api.pdap.PIMListListener;
公共类ContactListener实现了PIMListListener{
黑莓联系人列表;
DataBaseConnectivity dbConnectivity=新建DataBaseConnectivity();
已添加公共无效项(PIMItem arg0){
System.out.println(“添加的项=”;
String firstname=“无”;
字符串lastname=“无”;
字符串mobile=“无”;
字符串mobile1=“无”;
字符串mobile2=“无”;
String email=“无”;
字符串email1=“无”;
字符串web=“无”;
字符串company=“无”;
字符串地址=“无”;
字符串地址1=“无”;
字符串名称[]={”“};
字符串timeStamp=“无”;
PIMList contacts=arg0.getPIMList();
联系人=(联系人)arg0;
if(contacts.isSupportedField(Contact.NAME)){
试一试{
if(contact.countValues(contact.NAME)>0)
name=contact.getStringArray(contact.name,0);
如果(姓名[联系人姓名]!=null)
firstname=姓名[联系人姓名];
System.out.println(“FirstName=“+FirstName”);
如果(姓名[联系人姓名\家庭]!=null)
lastname=姓名[联系人姓名\家庭];
System.out.println(“LastName=“+LastName”);
}捕获(例外e){
System.out.println(“异常::”+e.getMessage());
}
}
if(contacts.isSupportedField(Contact.EMAIL)){
试一试{
如果(contact.countValues(contact.EMAIL)>0)
email=contact.getString(contact.email,0);
System.out.println(“电子邮件”+电子邮件);
如果(contact.countValues(contact.EMAIL)>1)
email1=contact.getString(contact.EMAIL,1);
System.out.println(“电子邮件”+email1);
}捕获(例外e){
System.out.println(“异常::”+e.getMessage());
}
}
if(contacts.isSupportedField(Contact.ORG)){
试一试{
如果(contact.countValues(contact.ORG)>0)
company=contact.getString(contact.ORG,0);
System.out.println(“公司”+公司);
}捕获(例外e){
System.out.println(“异常::”+e.getMessage());
}
}
if(contacts.isSupportedField(Contact.URL)){
试一试{
if(contact.countValues(contact.URL)>0)
web=contact.getString(contact.URL,0);
System.out.println(“web”+web);
}捕获(例外e){
System.out.println(“异常::”+e.getMessage());
}
}
if(联系人发布支持字段(联系人电话)){
试一试{
如果(contact.countValues(contact.TEL)>0)
mobile=contact.getString(contact.TEL,0);
System.out.println(“手机”+手机);
if(contact.countValues(contact.TEL)>1)
mobile1=contact.getString(contact.TEL,1);
System.out.println(“电话”+mobile1);
if(联系方式计数值(联系方式电话)>2)
mobile2=contact.getString(contact.TEL,2);
System.out.println(“电话”+mobile2);
}捕获(例外e){
System.out.println(“异常::”+e.getMessage());
}
if(contacts.isSupportedField(Contact.ADDR)){
试一试{
地址=”;
字符串[]地址arr=contact.getStringArray(
BlackBerryContact.ADDR,0);
for(int i=0;i