Search code examples
javaandroidqr-codezxing

How to encode multiple records in QR code while generating QR using zxing library?


I'm working in QR Code generator and scanner and I encode a single string record in QR Code successfully using zxing library in android but now I want to encode multiple records like name, address, email etc How can I do that?

Here is code for encode single record in QR using zxing:

public Bitmap encodeQR(String value) throws WriterException {

    BitMatrix bitMatrix;
    try {
        bitMatrix = new MultiFormatWriter().encode(value, BarcodeFormat.QR_CODE, 512, 512);
    } catch (WriterException e) {
        e.printStackTrace();
        return null;
    }

    return new BarcodeEncoder().createBitmap(bitMatrix);
}

Solution

  • You can create a JSON with what ever data you need and convert it to string

    and its easy to extract data from JSON when ever needed.

    For example:

       {
      "question": "Do you smoke?",
      "options": [
        "Yes",
        "No"
      ]
    }