0
我開發了一個代碼,但它不工作。請幫助我。如何從android中的SFTP服務器獲取文件列表?
ChannelSftp sftpChannel = (ChannelSftp) channel;
try {
Vector ls=sftpChannel.ls("/home/");
for(int i=0;i<ls.size();i++){
t.setText("\n"+ls.get(i)+"\n");
}
} catch (SftpException e1) {
// TODO Auto-generated catch block
}
這裏是例外:
11-06 12:29:15.801: E/AndroidRuntime(9624): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4267)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.ViewRootImpl.invalidateChild(ViewRootImpl.java:855)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:904)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.ViewGroup.invalidateChild(ViewGroup.java:4005)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.View.invalidate(View.java:8716)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.view.View.invalidate(View.java:8667)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.widget.TextView.updateAfterEdit(TextView.java:6265)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.widget.TextView.handleTextChanged(TextView.java:7909)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:8286)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.sendTextChange(SpannableStringBuilder.java:892)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:352)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:266)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:443)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.append(SpannableStringBuilder.java:257)
11-06 12:29:15.801: E/AndroidRuntime(9624): at android.text.SpannableStringBuilder.append(SpannableStringBuilder.java:29)
11-06 12:29:41.941: W/IInputConnectionWrapper(9624): showStatusIcon on inactive InputConnection
非常感謝它的作品,我有一個問題,我怎麼能列出這些文件在一個包含路徑和名稱的列表中,我需要那個緊急的 –
你可以使用[ListView](http://developer.android.com/reference/android/widget/ListView.html)。看我的編輯 – fiddler
我是否從main.xml @fiddler –