I have found the way to solve this problem.
Add a force sync after call the flush function. Now it's working
great.
Code is here:
fd = fOutputS.getFD();
fd.sync();
On 7月20日, 下午5时16分, Ryan Wang <[email protected]> wrote:
> We made a special device just look like a T-flash card. The program
> need to communicate with the device by the files. If we write
> something in a.txt, the COS run in the T-card like thing will write
> something in b.txt to answer. Here is the problem. If I use code like:
>
> FileOutputStream fOutputS = null;
> try {
> fOutputS = new FileOutputStream(hSTART);
> fOutputS.write(DataTmp);} catch (Exception e) {
>
> errorCode = ERRORINFO.WRITE_FILE_ERROR;
> DataLength = 0;} finally {
>
> if(fOutputS != null) {
> try {
> fOutputS.flush();
> fOutputS.close();
> } catch (Exception e) {
> }
> }
>
> }
>
> No error info return. And when I use the mobile app file explorer I
> can see the file do changed. But the COS give no answer. And if I
> unplug the card and connect to PC. I can see the file DIDNOT change at
> all. Why this issue happens? Because the FileOutputStream is buffer in
> the memory? and try to reduce the card write time?
>
> How can I write the file phisically immediately? Please please, It's
> so emergency. Otherwise we must cancel the whole project.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en