Hello all. Today I'm going to show you two very useful methods when working with the FileConnection API for JavaMe. This methods along with others not described in this post, can help you a lot:
//inside a class... /** * Checks whether the device has support for the * FileConnection API * @returntrue
if and only if the device supports the API *false
otherwise */ private boolean checkFileSupport() { if (System.getProperty( "microedition.io.file.FileConnection.version") != null) { return true; } return false; }
The last method tells you whether the device has support for the FileConnection API. Pretty handy when the application is developed for a wide range of mobile devices.
Next, we'll see a method that returns all the possible drives where the files can be stored in the mobile device.
Next, we'll see a method that returns all the possible drives where the files can be stored in the mobile device.
//inside a class... /** * Asks for the list of drivers where files can be stored * @returnVector
ofStrings
representing the name of * the drives where files can be stored */ private Vector getRoots() { Vector vRoots = new Vector(); if (checkFileSupport()) { Enumeration drivers = FileSystemRegistry.listRoots(); while (drivers.hasMoreElements()) { vRoots.addElement((String) drivers.nextElement()); } } return vRoots; }
Imagine your application takes snapshots, and you want to ask the user where to store them... with the help of the last method and a List, you can show to the user all the possible "hard drives" where he/she can save their pictures.
see ya soon!
References:
Getting Started with the FileConnection APIs. December 2004. Oracle [online].
Available on Internet: http://developers.sun.com/mobility/apis/articles/fileconnection/
[accessed on February 26 2011].
Available on Internet: http://developers.sun.com/mobility/apis/articles/fileconnection/
[accessed on February 26 2011].
Working with the Java ME FileConnection API on Physical Devices. March 2007. Java.net[online].
Available on Internet: http://today.java.net/article/2007/03/27/working-java-me-fileconnection-api-physical-devices
[accessed on February 26 2011].
Available on Internet: http://today.java.net/article/2007/03/27/working-java-me-fileconnection-api-physical-devices
[accessed on February 26 2011].
hello.. sir.. can a ask a favor. i hope you had a time to answer my question. i also used J2ME for computer vision. I need to capture a tomato and analyze the ripeness of the tomato. i used netbeans 7.0 and jdk 1.6..
ReplyDeletecan you teach me how to do. i need you help. hope you can read my comment. thank a lot..
Hello Anonymous. I supposed you are going to decide based on the color of the tomato, right? Check my email in my profile, so we can discuss a little bit about this application via email.
ReplyDeletebye
hello sir. i cannot connect on your email. this your email rigth @aa_lopez?. I supposed going to based on the color og tomato. and my problem is to capture the tomato. i had a code but it cannot save the image.
ReplyDeleteAnonymous, you could find my profile and email in this URL:
ReplyDeletehttp://www.blogger.com/profile/05599815066202691589
contact me so we can discuss better about this application.