android - two functions accessing database at the same time -


i have function , function b .

function runs in loop. updates data base every 6 seconds.

function b updates database when user changes .

during long run 2 functions trying access database @ same causing in sqlite crash.

please suggest way avoid this.

below function b

while(1)     {         tvaudiomgrinstance->updatedatabase();         if(errno != eintr)         {             // in android sleep() function takes argument seconds             rc = sleep(periodic_update_database_time);         }          if((rc != 0)||(errno == eintr))//even checking errno alone enough..as errno global thread alone         {             tvaudiomgrinstance->updatedatabase(); #if tvaudiomanager_log_enable                        alogd("exit audmgr pthread"); #endif             break;         }     } 

if use 1 helper instance shared between these functions, of db access code serial.

check this: http://touchlabblog.tumblr.com/post/24474750219/single-sqlite-connection


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -