Certify and Increase Opportunity.
Be
Govt. Certified Blackberry Apps Developer
The JSR 75 File Connection API gives your application the capability to read and write to the BlackBerry file system, both the internal flash memory and any memory card attached to your device. It also enables you to read data that other applications have written to the file system. This is especially useful for retrieving pictures, video, and other media that might be on your device. In the following sections, we’ll create a simple application to browse for photos from the device’s memory (internal or memory card) and display them on screen.
FileConnectionTest.java
package com.henry416.fileconnection; import net.rim.device.api.ui.UiApplication; public class FileConnectionTest extends UiApplication { public FileConnectionApplication() { FileConnectionScreen screen = new FileConnectionScreen(); pushScreen(screen); } public static void main(String[] args) { FileConnectionTest app = new FileConnectionTest(); app.enterEventDispatcher(); } }
FileConnectionScreen.java
package com.henry416.fileconnection; import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.component.Menu; import net.rim.device.api.ui.component.ObjectListField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.util.StringProvider; public class FileConnectionScreen extends MainScreen { private ObjectListField fileList; private String currentPath = "file:///"; public FileConnectionScreen() { setTitle("FileConnection"); fileList = new ObjectListField(); fileList.set(new String[] {"store/", "SDCard/"}); add(fileList); } protected void makeMenu(Menu menu, int instance) { super.makeMenu(menu, instance); menu.add(new MenuItem(new StringProvider("Select"), 10, 10) { public void run() { loadFile(); } }); } private void loadFile() { currentPath += fileList.get(fileList, fileList.getSelectedIndex()); try { FileConnection fileConnection = (FileConnection)Connector.open(currentPath); if (fileConnection.isDirectory()) { Enumeration directoryEnumerator = fileConnection.list(); Vector contentVector = new Vector(); while(directoryEnumerator.hasMoreElements()) { contentVector.addElement(directoryEnumerator.nextElement()); } String[] directoryContents = new String[contentVector.size()]; contentVector.copyInto(directoryContents); fileList.set(directoryContents); } } catch (IOException ex) { } } }
Apply for Blackberry Apps Certification Now!!
http://www.vskills.in/certification/Certified-Blackberry-Apps-Developer