| Reply | « Previous Thread | Next Thread » |
|
Hi ,
I want to store a number of .midi files and then read those through my Midlet. After storing certain number of files the Emulator throws the RecordStoreFullException. If this is the case with emulator .... actual phone will surely throw this error after storing few .midi s. Is there any other Persistense storage mechanism which will allow me to store unlimited number of files (limited to phone memory, even in memeory card) and then read it through the Midlet. If I use nokia API it will not work in other phones right? So is there any other Platform independant way to do it ? Thanx. |
|
Quite a few phones support nowadays FileConnection API (JSR-75). With that API you can save the MIDI files into the file system
http://www.forum.nokia.com/info/sw.n..._0_en.zip.html http://developers.sun.com/mobility/a...ion/index.html Hartti |
|
Just one more question before starting on this. How can i access files on 6600 ? (I tried to install some JSR-75 example .jar files on this but it does not work)Is there any method ?
|
|
Ok, I should have asked which phone you are trying to use. 6600 does not support FileConnection API so you need to use RMS in staring the data.
You cannot add the File Connection API fuctionality in the Java ME environment after manufacturing. Hartti |
|
I tried this example on emulator and it gives the expected output.
But when i tried this on N70 and 6230i ...it shows only the root directories . And it does not show the file's contents. Can u pls tell me what the problem might be ? (when i ran this on emulator i changed the : "c:/" to "foldername") package test_file; import javax.microedition.lcdui.*; import javax.microedition.io.file.*; import javax.microedition.io.*; import java.io.*; import java.util.*; public class Displayable2 extends Form implements CommandListener { StringItem stringItem1; String root = ""; StringBuffer sb = new StringBuffer(); StringItem stringItem2; byte by[] = null; /** Constructor */ public Displayable2() { super("Displayable Title"); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { // Set up this Displayable to listen to command events stringItem1 = new StringItem("", ""); stringItem2 = new StringItem("", ""); stringItem1.setText(""); setCommandListener(this); // add the Exit command addCommand(new Command("Exit", Command.EXIT, 1)); this.append(stringItem1); this.append(stringItem2); getRoots(); createFile(); showFile("mynewfile.txt"); } private void getRoots() { try { Enumeration drives = FileSystemRegistry.listRoots(); System.out.println("The valid roots found are: "); while (drives.hasMoreElements()) { root = (String) drives.nextElement(); sb.append(root + "\n"); stringItem1.setText(sb.toString()); System.out.println("\t" + root); } } catch (Exception ex) { System.out.println(ex); } } public void createFile() { try { FileConnection filecon = (FileConnection) Connector.open("file:///C:/mynewfile.txt"); // Always check whether the file or directory exists. // Create the file if it doesn't exist. if (!filecon.exists()) { filecon.create(); } OutputStream is = filecon.openOutputStream(); String s = new String("we are the best kept secret of the universe,our mission is to monitor extra terrestrial activities onearth"); byte b[] = s.getBytes(); by = s.getBytes(); is.write(b, 0, b.length); filecon.close(); } catch (Exception ioe) { System.out.println("EE "+ioe); } } public void showFile(String fileName) { try { FileConnection fc = (FileConnection) Connector.open("file:///C:/" + fileName); if (!fc.exists()) { throw new IOException("File does not exist"); } InputStream is = fc.openInputStream(); byte b[] = by; int length = is.read(b, 0, b.length); stringItem2.setText("Content of " + fileName + ": " + new String(b, 0, length)); System.out.println ("Content of " + fileName + ": " + new String(b, 0, length)); } catch (Exception e) { } } /**Handle command events*/ public void commandAction(Command command, Displayable displayable) { /** @todo Add command handling code */ } } |
|
Hi,
I've heard about a workaround (below) for acessing the filesystem of a Nokia 6600. Not that it is not standard (it uses classes from com.symbian.midp.runtime package) and also, I have never tested it myself... Reading files from J2ME on a 6600 http://www.mobile-j.de/snipsnap/spac...J2ME+on+a+6600 Kind regards, Juarez Alvares Barbosa Junior - Brazil |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Good looking xHTML | mreaves | Browsing and Mark-ups | 0 | 2006-09-01 14:43 |
| USB Mass Storage Connectivity | g_peeyush | PC Suite API and PC Connectivity SDK | 0 | 2006-07-07 10:21 |
| Is "1 day free license" a good approach? | MobileVisuals | Digital Rights Management & Content Downloading | 0 | 2006-01-12 20:24 |
| A good place to start. | amontandon | General Symbian C++ | 1 | 2005-02-05 10:28 |
| MMS Header Encoding mechanism used? | LearningCurve | General Messaging | 3 | 2004-04-29 17:53 |