0

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)
}
syam
  • 14,701
  • 3
  • 41
  • 65
Dannyfly
  • 1
  • 1
  • Can you post your code? What version of Android are you using? – HeatfanJohn May 03 '13 at 13:06
  • I even call fclose() after every fwrite() but it is the same situation in case 1 and after some test, I guess the situation would never change as long as more than 2 file exist in one directory. is my view false? why? – Dannyfly May 03 '13 at 14:05

0 Answers0