4
我已經在資產文件夾中存儲了一個XML文件,並且我想要檢索存儲在android資產中的數據XML文件,併爲我提供了一個解決方案。如何從android資產中獲取XML數據?
<Response>
<RequestID>1001</RequestID>
<FunctionStatus></FunctionStatus>
<Message></Message>
<Result>
<Banner>
<Banner_List>
<Banner_id>3794</Banner_id>
<Banner_url>http://www.metromatinee.com/agile_dogs/05.jpg</Banner_url>
<Movie_name>Rose Guitarinaal</Movie_name>
<gender>Movie</gender>
</Banner_List>
</Response>
我試圖InputStream is = getAssets().open("demo.xml");
但異常事件引起
任何幫助.. ???
03-27 11:03:04.939: E/AndroidRuntime(432): FATAL EXCEPTION: main
03-27 11:03:04.939: E/AndroidRuntime(432): java.lang.NullPointerException
03-27 11:03:04.939: E/AndroidRuntime(432): at android.content.ContextWrapper.getAssets(ContextWrapper.java:74)
03-27 11:03:04.939: E/AndroidRuntime(432): at com.service.example.DemoBussinessExecutePage.executeBussinessFunction(DemoBussinessExecutePage.java:230)
03-27 11:03:04.939: E/AndroidRuntime(432): at com.service.example.Service_Manager.executeBussinessFunction(Service_Manager.java:38)
03-27 11:03:04.939: E/AndroidRuntime(432): at com.service.example.Service_class$1.onClick(Service_class.java:57)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.view.View.performClick(View.java:2408)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.view.View$PerformClick.run(View.java:8816)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.os.Handler.handleCallback(Handler.java:587)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.os.Handler.dispatchMessage(Handler.java:92)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.os.Looper.loop(Looper.java:123)
03-27 11:03:04.939: E/AndroidRuntime(432): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-27 11:03:04.939: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-27 11:03:04.939: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-27 11:03:04.939: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-27 11:03:04.939: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-27 11:03:04.939: E/AndroidRuntime(432): at dalvik.system.NativeStart.main(Native Method)