Remove Portable Devices File Using Java

364 views Asked by At

I found the solution to above problem using JMTP library on

http://code.google.com/p/jmtp/

here is the code

import be.derycke.pieter.com.COMException;
import be.derycke.pieter.com.Guid;
import java.io.*;
import java.math.BigInteger;
import jmtp.PortableDevice;

public class Jmtp {

public static void main(String[] args) {
    PortableDeviceManager manager = new PortableDeviceManager();
    PortableDevice device = manager.getDevices()[0];
    device.open();

    System.out.println(device.getModel());

    System.out.println("---------------");

    // Iterate over deviceObjects
    for (PortableDeviceObject object : device.getRootObjects()) {
        // If the object is a storage object
        if (object instanceof PortableDeviceStorageObject) {
            PortableDeviceStorageObject storage = (PortableDeviceStorageObject) object;

            for (PortableDeviceObject o2 : storage.getChildObjects()) {
                System.out.println(o2.getOriginalFileName());
            }
         }
      }
    manager.getDevices()[0].close();
    }
 }

but I want to remove file inside the device?. How to remove the file using this library

1

There are 1 answers

0
selendroid On

It can be achieve by the help of java.io package. If the device is discoverable than you can explore it with help of java.io.