Android: Cannot Find Plist In Res/raw Using Xmlwise
I am trying to read a plist into my android app using xml wise. This is my code String path = 'android.resource://' + context.getPackageName() + '/' + R.raw.nameofplist; Map
Solution 1:
I struggled to find an answer to this too... but I worked it out eventually.
Here's my solution based on a plist file called airports.plist sitting in the res/raw folder.
Map<String, Object> properties = null;
try {
InputStream inputStream =getResources().openRawResource(R.raw.airports);
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
properties = Plist.fromXml(sb.toString());
//TODO do something with the object here
System.out.println("plist object... "+properties);
} catch (Exception e) {
e.printStackTrace();
} finally {
br.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
Hope this helps someone!
Post a Comment for "Android: Cannot Find Plist In Res/raw Using Xmlwise"