I have function A and function B .
Function A runs in loop. updates the data base every 6 seconds.
Function B updates the database when user changes something .
During the long run this two functions are trying to access the database at the same causing in the sqlite crash.
Please suggest a way to avoid this.
Below is my function B
while(1)
{
tvAudioMgrInstance->updateDatabase();
if(errno != EINTR)
{
// In Android sleep() function takes argument as seconds
rc = sleep(PERIODIC_UPDATE_DATABASE_TIME);
}
if((rc != 0)||(errno == EINTR))//even checking errno alone is enough..as errno is global to the thread alone
{
tvAudioMgrInstance->updateDatabase();
#if TVAUDIOMANAGER_LOG_ENABLE
ALOGD("Exit AUDMGR Pthread");
#endif
break;
}
}