This tutorial illustrates the basic use of the 51Degrees API. It will show you how to create a provider, how to create a dataset and how to obtain a value for the IsMobile property.
Code and Explanation
Example of using 51Degrees Pattern Detection to output a CSV file containing
the properties of all hardware devices in the data set being used.
The example illustrates:
Loading a Provider from a Disk-based (Stream) Pattern Dataset
provider = new Provider(StreamFactory.create
(Shared.getLitePatternV32(), false));
Getting the values for some properties of the device
Values isMobile = profile.getValues("IsMobile");
A property may have multiple values. Helper methods convert the list of
values into a Boolean, Double etc.
For example:
isMobile.toBool();
You can run
MetadataExample.main(java.lang.String[])
for a listing of which properties
are available in the dataset supplied with this distribution.
Summary
In this tutorial you have seen how to use the dataset to run through all the devices it contains, and all the properties for each of those devices. The example outputs all the devices and their properties to a CSV file for analysis. For a full list of properties and the data file versions they exist in please see the
Property Dictionary
.