How can I access some resources from another package?

Put your problem here if it does not fit any of the other categories.

How can I access some resources from another package?

Postby tearcry » Sun Mar 30, 2008 3:20 pm

I wrote a lib and packed it to JAR file.
In the file,there are some xml file and I need parse the file in the code,
As the lib Class is Lib
I tried this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. InputStream stream=Lib.Class.getClassLoader().getResourceAsStream("/a/b/c.xml");
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


the other non-Android projects run correctly , they can obtain the resources needed, but when an Android project call the lib, it failed. I will also try to put that xml file in Android project code package, and then use this method to access, still not result,the path is exactly right, but the stream I got is null.
anyone can tell me why?

the lib contains only one method,
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public String getText(String str);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


you can call getText("Gansu"), will return 甘南
the lib and the test code in the attachment

Forgive me for bad English
thanks
Attachments
CallTest.rar
the simple code I test
(36.45 KiB) Downloaded 47 times
tearcry
Freshman
Freshman
 
Posts: 8
Joined: Sat Mar 29, 2008 1:17 pm
Location: CN

Top

Postby tearcry » Sun Mar 30, 2008 3:44 pm

Oh it's a bug of Android.
the details in the link
http://code.google.com/p/android/issues/detail?id=173
tearcry
Freshman
Freshman
 
Posts: 8
Joined: Sat Mar 29, 2008 1:17 pm
Location: CN

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 12 guests