Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Problem in wipe data

Hi, I am getting problem when I wipe contact list and call log in os6.0.In os4.7 following code working perfectly in simulator In so 6.0 I am getting error source code not found .I am running this code in background thread that start using alternate entry point.

 

.....

 

 

Public static void main(String rags[])
    {
        EventLogger.register(Constants.PERSISTENT_BG_LOG, Constants.APP_NAME, EventLogger.VIEWER_STRING);
        if(args != null && args.length > 0 && args[0].equals("gui"))
        {
            iFindForBBApplication iFindApp = new iFindForBBApplication();
            iFindApp.enterEventDispatcher();
            iFindApp.getAppEventLock();
        }
        else
        {
                try
                {                   
                  //  startThread();
                  // Thread.sleep(2000);
                   if(mBackgroundThread==null)
                   {
                       System.out.println("Background thread started from main: thread is null");
                       startThread();
                   }
                   else
                   {
                       if(!BackGroundApp.isAlive)
                       {
                            System.out.println("Background thread started from main: thread is not alive");
                            startThread();
                       }
                   }
                  
                  // mBackgroundThread=new BackGroundApp();
                   //mBackgroundThread.start();
                 
                }               
                catch(Exception e)
                {
                    System.out.println("Exception in background thread");
                     e.printStackTrace();
                }          
        }
      
    }  

 

...

In BG thread..

 

//here, it wipe the contact data         
            public boolean wipeContactData()
            {
                        boolean retValue = false;
                        try
                        {
                                    if(pim==null || contactList==null )
                                    {
                                            pim=(BlackBerryPIM)PIM.getInstance();
                                            contactList=(BlackBerryContactList)pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_WRITE);
                                            contactList.addListener(new PimItemListener());
                                    }
                                    try{
                                        if(contactList!=null)
                                            enumList=contactList.items(BlackBerryContactList.SEARCH_GROUPS|BlackBerryContactList.SEARCH_CONTACTS);
                                        //enumList=contactList.items(BlackBerryContactList.SEARCH_CONTACTS );
                                    }catch(Exception e)
                                    {
                                        System.out.println("BG:Exception in removing contact : " + e.toString() );
                                        e.printStackTrace();
                                    }
                                   
                                    int i=0;
                                    if(enumList!=null)
                                    {
                                        while(  enumList.hasMoreElements())
                                        {
                                            try{                                              
                                                    contact=(BlackBerryContact)enumList.nextElement();
                                                    if(contact.UID!=-1)
                                                    {                                      
                                                        ((ContactList)contactList).removeContact((Contact)contact);
                                                    }                                           
                                                }catch(PIMException  e)
                                                {
                                                    System.out.println("BG:Exception in removing contact loop: " + e.toString() );
                                                    e.printStackTrace();
                                                }
                                                catch(NullPointerException  e)
                                                {
                                                    System.out.println("BG:Exception in removing contact loop: " + e.toString() );
                                                    e.printStackTrace();
                                                }
                                                catch(SecurityException  e)
                                                {
                                                    System.out.println("BG:Exception in removing contact loop: " + e.toString() );
                                                    e.printStackTrace();
                                                } 
                                              
                                                i++;
                                        }
                                    }
                                    System.out.println("BG:no of contact persons"+i);
                                                  
                                retValue = true;
                        }
                        catch(Exception e)
                        {
                            System.out.println("BG:Exception in removing contact : " + e.toString() );
                            e.printStackTrace();
                        }           
                    return retValue;
            }

 //here, it wipe the call Log details          
            public void wipeCallLogDetails()
            {
                PhoneLogs _callLog=PhoneLogs.getInstance();
                int noofNormalCalls = _callLog.numberOfCalls(PhoneLogs.FOLDER_NORMAL_CALLS);
                int noOfMissCalls=_callLog.numberOfCalls(PhoneLogs.FOLDER_MISSED_CALLS);
               // for(int i=0;i<noofNormalCalls;i++)
                for (int i = noofNormalCalls - 1; i >= 0; i--)
                {
                    //PhoneCallLog callLog=(PhoneCallLog)_callLog.callAt(i, _callLog.FOLDER_NORMAL_CALLS);
                    try
                    {
                         _callLog.deleteCall(i,PhoneLogs.FOLDER_NORMAL_CALLS);
                       // PhoneCallLog callLog=(PhoneCallLog)_callLog.callAt(i, _callLog.FOLDER_NORMAL_CALLS); 
                       // CallLogDelete.callLogAdded(callLog);
                    }
                    catch(Exception e)
                    {
                        System.out.println(e.toString());
                        e.printStackTrace();
                    }
                }
               // for(int i=0;i<noOfMissCalls;i++)
                for (int i = noOfMissCalls - 1; i >= 0; i--)
                {
                    try
                    {
                      
                        _callLog.deleteCall(i,PhoneLogs.FOLDER_MISSED_CALLS);                    
                       // PhoneCallLog callLog=(PhoneCallLog)_callLog.callAt(i, _callLog.FOLDER_MISSED_CALLS);
                        //CallLogDelete.callLogAdded(callLog);
                    }catch(Exception e)
                    {
                         System.out.println(e.toString());
                         e.printStackTrace();
                    }
                }
            }          

 

please help me on this.........

 

 

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,677
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.  What version of BlackBerry Java SDK are you using?  What line of code is triggering the error?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

[ Edited ]

I am using BB OS6.0 and testing on simulator torch 9800 and BB OS5.0 simulator storm 9550 which wipeCallLogdetails() does not remove call log deatils

and wipeContactData() gives crashes the application on line

 

 ((ContactList)contactList).removeContact((Contact)contact)

 

and show message source code not found. when i run this application again than it remove the contact from list.

In OS4.7 with storm 9530 simulator is's working fine.

 

Is there any other methods to wipe call Log and remove contact......?

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,677
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

What exception do you see in your System.out.println statement after removeContact is called?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

My application has crashed and said source code not found .Illegal state exception i can see in console.bt not sure this is due to this .bcos  i m not able to caught this right now.

 

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,677
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

The source code not found warning just indicates that you are at a break point you don't have source code for (internal code).  Try catchting Exception after your removeContact call to get it's toString details.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

What wiil be solution for smooth running the application.these code is running in background thread that run through alternate entry point.Is this creating some problem?

why not callLog is deleted from wipeCall().Is anything is missing from code?

Can you Please explain these thing in some details.So, I can resolve  my problem.

Please use plain text.
BlackBerry Development Advisor
MSohm
Posts: 14,677
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook

Re: Problem in wipe data

Is your wipeCall code actually running or is your application crashing before it gets to that (deleting contacts)?

 

If you can provide the .toString details of the exception you are receiving it will help in diagnosing the problem.

 

Does your application extend Application or UiApplication.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

My application extends UiApplication.There is Nothing caught in exception before that application crashed and said source code not found.I would like to pay attention on another mehtod wipeCallLog.Where is doesn't wipe any callLog.Actually code deleted the call details but result is not visible in callLog .Still this is showing there....

Is there any problem in code .Please see the code anything missing

Please use plain text.
Contributor
kaushikdeepak
Posts: 15
Registered: ‎12-22-2010
My Device: Not Specified

Re: Problem in wipe data

 There is one exception in application also coming

java.lang.IllegalStateException: no application instance.

I running this code in background thread that run through alternet entry point.

How can i get my instance of application in this thread which always active after application closes.

Please use plain text.