phonegap html5 android synchonous Filesystem IO

2019-07-20 05:56发布

How can I read and write files synchronously, using PhoneGaps Filesystem API? Is there a an synchronous wrapper available?

2条回答
做自己的国王
2楼-- · 2019-07-20 06:30

Because of the way the Java-to-JavaScript bridge on Android works, it is pretty much impossible to do a synchronous implementation of File IO. This is because each Java object in Android that is bound to the JavaScript environment runs on its own thread.

Use the existing File API available in PhoneGap - but use it asynchronously. Register a callback with it that will notify your app that an IO process is complete.

查看更多
欢心
3楼-- · 2019-07-20 06:48

There is no way to access files synchronously through the provided api. Guessing from the way phonegap is implemented i doubt that you can write a plugin to do this synchronously.

查看更多
登录 后发表回答