2011-07-20 34 views
1

如何在以下代碼中提供SD卡文件路徑?如何在下面的代碼中提供SD卡文件路徑?

 
String s="file:///sdcard/tempImage.png"; 
parameters.putString("attachment","{\"name\":\"Android Facebook application By Martin\",\"href\":\"http://www.google.com/\",\"caption\":\"By google Technology \",\"description\":\"Description :- Android and iphone application \",\"media\":[{\"type\":\"image\",\"src\":\'"+ s + "',\"href\":\"http://s.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"for more tips click here\",\"href\":\"http://www.google.com/\"}}}"); 

我使用上面的代碼從我的SD卡在Facebook牆上上傳圖片。但上述代碼不起作用,請幫助我。

+0

文件:///sdcard/tempImage.png是URI,而不是文件路徑。 –

+0

嗨,Jett Hsieh然後什麼是SD卡的文件路徑? –

回答

2

試試下面的代碼

File mFile = new File(Environment.getExternalStorageDirectory(), tempImage.png); 
+1

Saurabh這不是工作。 –

+0

使用Log.e確保路徑是否正確(「File exists」,「」mFile.exist());如果返回true,那麼還有一些其他問題 – ingsaurabh

+0

文件在我的SD卡上存在,因爲我用這個文件也是上傳到Twitter。 –

1
String filePath=Environment.getExternalStorageDirectory()+"/tempImage.png"; 
File mFile = new File(filePath); 
+0

hotveryspicy,這是行不通的。 –

+0

在控制檯中打印路徑,並查看路徑是否正確? –

+0

是的,我檢查它,路徑打印是「/mnt/sdcard/tempImage.png」。 –

相關問題