You Are Here:

Community: Developer Discussion Boards

#1 Old Good storage mechanism ? - 2007-06-21, 13:32

Join Date: Apr 2007
Posts: 35
ziyaaf's Avatar
ziyaaf
Offline
Registered User
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.
Reply With Quote

#2 Old Re: Good storage mechanism ? - 2007-06-22, 02:17

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#3 Old Re: Good storage mechanism ? - 2007-06-22, 14:03

Join Date: Apr 2007
Posts: 35
ziyaaf's Avatar
ziyaaf
Offline
Registered User
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 ?
Reply With Quote

#4 Old Re: Good storage mechanism ? - 2007-06-22, 19:21

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#5 Old Re: Good storage mechanism ? - 2007-06-26, 13:15

Join Date: Apr 2007
Posts: 35
ziyaaf's Avatar
ziyaaf
Offline
Registered User
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 */
}

}
Reply With Quote

#6 Old Re: Good storage mechanism ? - 2007-06-26, 15:01

Join Date: Dec 2005
Posts: 1,886
Location: Brazil
Send a message via MSN to juarezjunior Send a message via Skype™ to juarezjunior
juarezjunior's Avatar
juarezjunior
Offline
Forum Nokia Champion
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia