Choosing the best format for our data
While developing other recipes, we have seen different ways of storing our data in an NFC tag. From a simple plain text to a raw object, it all depends on the data we need to store. In this recipe, we will learn about some other formats to store our data.
How to do it…
We will create several NdefMessages
that contain a product representation in several formats by performing the following steps:
Open Eclipse and create a new Android application project named
NfcBookCh10Example2
and a package namednfcbook.ch10.example2
.Download the
google-gson
library from https://code.google.com/p/google-gson/ and import the.jar
file to thelibs
folder in the project.Set the minimum SDK version to 16 using the following code:
<uses-sdk android:minSdkVersion="16" />
Add the strings given in the following code to the
strings.xml
file available atres/values/
:<string name="label_raw">Raw</string> <string name="label_json">JSON</string> <string...