Is there something equivalent to plist files on Android, like on iOS?

When programming iOS applications, we can have the data in a plist file, and then read it to / from on the same line as NSDictionary. Does something like this exist on Android? I already made an iOS app with a plist file containing a couple of hundred entries. This is just normal XML, isn't it? So, can I parse the file using SAX / DOM Java parser?

+6
source share
3 answers

Plist files exist in one of three forms:

  • NeXTSTEP format (which is very similar to JSON). This is deprecated.
  • XML format (which can be easily parsed on any platform)
  • Binary format (which is not documented by Apple, but saves space compared to the XML format)

If the plist file you want to parse is in NeXTSTEP or XML format, it is easy to create a parser for it using existing tools on most platforms. In the case of the XML format, yes, you can use the built-in Java parser.

If the plist file is binary, you will either have to collapse your own parser or use an existing third-party class. One of them exists at http://www.java2s.com/Open-Source/Java-Document/Swing-Library/jide-oss-2.8.3/com/jidesoft/plaf/aqua/BinaryPListParser.java.htm , but I did not use it myself, so I can not vouch for its accuracy / quality / performance.

+4
source

In addition to the other answers presented here, I would like to look at the nature of the data you need in your plist file. If your plist file is just a flat NSDictionary of string values ​​and not a structured value dictionary, then you have the option of using the Java Properties object:

Android Java Properties

Again, this will not help you if your requirements include the fully structured equivalent of plist files. But if you need a simple dictionary with key values ​​stored in a text file, the java.util.Properties path is the path.

+1
source

ultimately, plist is just an XML document with a specific format. You should not try to make your own in java using a parser. You can also use the xml file to suit your needs.

0
source

Source: https://habr.com/ru/post/897042/


All Articles