You Are Here:

Community: Developer Discussion Boards

#1 Old DataElement's removeElement() return false - 2007-08-24, 06:24

Join Date: Jun 2007
Posts: 12
selenatan
Offline
Registered User
i am getting a false from base.removeElement(de) whenever i try to remove the item from being broadcasted. it works fine when i run on netbeans but not on the mobile phone. any one knows why?

Code:
    public boolean changeContact(String name, boolean isBroadcasted) {

        DataElement base = record.getAttributeValue(ATTRIBUTE_ID);
        DataElement de = (DataElement)dataElements.get(name);
        
        if (de == null) {
            de = new DataElement(DataElement.STRING, name);
            dataElements.put(name, de);
        }
        
        if (isBroadcasted) {
            base.addElement(de);
        } else {
            if(!base.removeElement(de)){
                return false;
            }
        }
        
        record.setAttributeValue(ATTRIBUTE_ID, base);
        
        try {
            localDevice.updateRecord(record);
        } catch (ServiceRegistrationException e) {
            System.err.println("Can't update record now for: " + name);
            
            return false;
        }
        
        System.out.println("updated base");
        return true;
    }
Last edited by selenatan : 2007-08-24 at 07:13.
Reply With Quote

#2 Old 2007-08-26, 11:29

Join Date: Mar 2003
Posts: 2,617
traud
Offline
Super Contributor
Is this Java? In the future ask questions like those there…

Is the object ‘dataelements’ a Hashtable? First of all make sure, the DataElement ‘de’ is within your list of DataElements (object ‘base’). First check via references (removeElement does this for you), second check via content. The latter cannot be done with removeElement as the class ‘DataElement’ does not implement equals. Please see the JSR-82 API for details. So my guess is, the reference was somehow changed in your real device and you have to remove the DataElement manually via content comparism: de (of dataelements) != de (of base) and false == de.equals(de of base) but de.getValue().equals((de of base).getValue()). So you have to code a bit more.

All wild guessing, as I neither know your used device nor have I played with removeElement myself, yet. Just an idea why this workes in IDE and not in real device.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Python for S60 1.4.0 released jplauril Python 43 2009-05-24 10:22
How to port Symbian OS String Descriptors birol.sekerci General Symbian C++ 17 2007-11-08 17:24
CMdaAudioOutputStream Not working with EXEDLL target fnagaton General Symbian C++ 6 2005-10-03 06:51
关于Float的问题,急死了,各位帮忙一下,谢谢! show_up Other Programming Discussion 关于其他编程技术的讨论 4 2004-08-17 09:57
How to make singleton rownak_hasan Symbian Tools & SDKs 2 2003-02-07 00:15

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia