开发者

Android Development: Advice on Efficient FTP Code

In my app I have an FTP file browser, and I was wondering the following to try and acheive efficient FTP code:

Should I connect, login, perform actions, then disconnect each time I want to download/upload a file or list files?

or

Should I connect and login when the file browser is loaded, then performs actions whenever is necassary, then at the end disconnect when the file browser is closed?

or do you have any other suggestions of when to connect/disconnect?

Sorry if my question isn't good enough, or is stupid. I'm just curious as some tutorial I've seen they disconnect straight after performing an action and I wasn't sure if you should eac开发者_如何学JAVAh time you perform an FTP-related action or not.

Thanks, Alex.


You might have to measure this, but the answer to your question depends on how frequently does the app needs to perform some kind of ftp transfer. If the application needs to be perform lots of ftp transfer then there is no point dropping and creating new connection.

As far as I know, the ftp connection object is not very heavy and the following thread discussed a good pattern on using FTP in android.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜