0

I have written this code on java class..

public void getImageBarcode(String data,String path)
{
     PDF417 barcode = new PDF417();
     barcode.setProcessTilde(true);
     barcode.setData(data);

     barcode.setEcl(PDF417.ECL_2);
     // 3 - 90
     barcode.setRowCount(40);
     // 1 - 30
     barcode.setColumnCount(8);
     barcode.setDataMode(PDF417.MODE_AUTO);

     barcode.setUOM(0);
     barcode.setX(2);
     barcode.setBarRatio(3);
     barcode.setLeftMargin(10);
     barcode.setRightMargin(10);
     barcode.setTopMargin(10);
     barcode.setBottomMargin(10);
     barcode.setResolution(72);
     barcode.setRotate(0);


     try {
        barcode.renderBarcode(path);
     } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
}

I will call this method in my android activity on button click..

public void onClick(View arg0) {
    // TODO Auto-generated method stub
    String binarydata="12345678 abcdefgh 12345678 abcdefgh 12345678 abcdefgh 12345678";
    String pathimage="E://pdf417e.gif";
    barcode b= new barcode();
    b.getImageBarcode(binarydata,pathimage);

But when I click on the button I get an error.. While I am trying to create image in specified path...

I got fatal exception error..

When I run only java class function in java application it will work but in android application I get an error...

I've put all library files also...

Ivan Ferić
  • 4,725
  • 11
  • 37
  • 47

1 Answers1

0

In Android, you cannot write files into any location you want and also it uses Unix notation so E://pdf417e.gif is not valid. Use ContextWrapper.getFilesDir() to get your the private work folder for you application as described here, also read about the possible data storage options.

Community
  • 1
  • 1
Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93