Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

BGS5T deleting the file | Telit Cinterion IoT Developer Community

November 5, 2014 - 3:43pm, 5214 views

Hi,

I am using FileConnection, to write to files and save data for the nex time that midlet is run. But I wan't to refresh some data and for that I need to clear everything inside the file or delete it. So I tryed this pice of code:

String filename_new = "file:///a:/users.txt";
        FileConnection fc=null;
       fc = (FileConnection) Connector.open(filename_new, Connector.READ_WRITE);
        if(fc.exists())
        {
            fc.delete();
            fc.close();
        }
        fc = (FileConnection) Connector.open(filename_new, Connector.READ_WRITE);
        fc.create();
        OutputStream os = fc.openDataOutputStream();

But I am getting exception: java.io.IOException: cannot delete file. Do I need to change any settings or what is the proper way to delte file?

Regards

Jure