2012-02-01 27 views
0

你知道它爲什麼不識別我的路徑嗎?來自Android資產的文件路徑未被識別

Uri path = Uri.fromFile(new File("assets/test.xml")); // tried with "file:///android_asset/test.xml" 
String fileIn = path.getPath(); 
FileInputStream fis = new FileInputStream(fileIn); 

我在最後得到一個FileNotFound錯誤,fis變量。

非常感謝。

+0

[在Android中使用資產文件夾中的xml文件路徑]可能的重複(http://stackoverflow.com/questions/9077302/using-filepath-for-an-xml-from-assets-folder-in-android ) – 2012-02-01 08:54:00

回答

0

getAssets()將返回資產文件夾。你會看到一個文件

InputStream in = getAssets().open("test.xml"); 

如果你是這樣做我們的活動。然後你需要調用context.getAssets();

+0

啊......太蠢了。你是對的。謝謝 – user1140656 2012-02-01 09:14:25