I'm facing problem when I try to erase data in NFC tag. I'm using MifareUltralight type NFC tag. Please some one help me to find solution. Here is my code. I got this code from here
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
mytag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
NdefFormatable formatable = NdefFormatable.get(mytag);
if (formatable != null) { // Here I'm getting formatable null
try {
formatable.connect();
try {
formatable.format(methodGetMsg());
} catch (Exception e) {
// let the user know the tag refused to format
}
} catch (Exception e) {
// let the user know the tag refused to connect
} finally {
try {
formatable.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
// let the user know the tag cannot be formatted
}