I met a problem recently. I need to write some tmp data to the file(use API fwrite) in /data/data/com../tmp on Android.
The test program just run on one thread. and write data several hundred KB one time.
case 1: In this case, I create 2 file in this path first, and then write this 2 tmp files by turns.
The write process would pause few time once in a while , sometime it would few seconds. and if just write one tmp(but fopen this 2 file) file in this case, it is the same situation.
case 2: If there just one tmp file exist in this directory. the write process would never pause..
Why the write process would pause continuously in case 1 ?
Thank for your help.
Update:
I have tested several versions of Android including 2.3.7 , 4.0.3, 4.1
The code is:
FILE *tmp1 = fopen(tmp1,"wb");
FILE *tmp2 = fopen(tmp2,"wb");
FILE *swap = tmp1;
while(..) {
if (..)
swap = tmp2;
else
swap = tmp1;
fwrite(.., swap)
}