Create File in any Path on Mobile Device
I want to create a file on mobile phone and the file path is determined by the user. In my mobile phone (Nokia) the list is that:
Phone Memory:/ , C:/ , Memory Card:/, E:/.
The file is created in Memory Card:/ and E:/ but in the other path I get error.
This application will run any mobile phone and if I experienced this 开发者_如何学JAVAproblem for only one mobile device I might this problem for all mobile device. How could I deal with? Thanks...
I dont think this is possible, but you can connect to the mobile device with the MTP-Protocol. Here the Java MTP libary http://code.google.com/p/jmtp/.
package test;
import jmtp.PortableDevice;
import jmtp.PortableDeviceManager;
import jmtp.PortableDeviceObject;
import jmtp.PortableDeviceStorageObject;
public class FileConnectionTest {
public static void main(String[] args) {
PortableDeviceManager manager = new PortableDeviceManager();
PortableDevice device = manager.getDevices()[0];
// Connect to my mp3-player
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.getName());
}
}
}
manager.getDevices()[0].close();
}
}
Console output...
Sansa Clip+ 8GB
---------------
Music
Playlists
Record
Podcasts
Audiobooks
Service
DevIcon.fil
Albums
See this nokia forum discussion. It will helps you.
精彩评论