Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 9
Registered: ‎12-30-2008
My Device: Not Specified
Accepted Solution

Strange... SDcard disapears after the 8th execution...

[ Edited ]

I have the following code to read some data from a file:

 

 

private void leer_reglas() {
Log("Leyendo fichero de reglas...");

reglas_leidas = 0;

try {
FileConnection fc = (FileConnection) Connector.open(
"file:///SDCard/BlackBerry/DDsmsFw/reglas.txt",
Connector.READ);

if (!fc.exists()) {
Log("ERROR: El fichero no existe");
}
InputStream is = fc.openInputStream();
long tam=fc.fileSize();
int tam2= Integer.parseInt(Long.toString(tam));
if (debug) Log("tamaño: "+Integer.toString(tam2));
byte b[] = new byte[tam2];
int length = 0;

length = is.read(b, 0, tam2);
String tmp = new String(b, 0, length);

int i = 0, j = 0;
while (tmp.substring(i).indexOf("\n") != -1) {
j = tmp.substring(i).indexOf("\n") - 1;
String kk = tmp.substring(i, i + j);
regla[reglas_leidas] = new ReglaClass();
regla[reglas_leidas].inicializa_regla(kk);
i = i + j + 2;
if (debug)
Log("regla " + Integer.toString(reglas_leidas) + ": "
+ regla[reglas_leidas].muestra_regla());

reglas_leidas++;
}

Log("Reglas leidas: " + Integer.toString(reglas_leidas));

// recibir_sms_prueba("5051 MCN S4 CAIDA DE LO QUE TU QUIERAS");

fc.close();


} catch (IOException e) {
Log(e.toString());
System.err.println(e.toString());
} catch (Exception e) {
Log(e.toString());
System.err.println(e.toString());
}

}

 

 I can call the funtion leer_reglas() from the menu. All the process works fine until 8 times. No problem with the first 7 times. In the 8th the SDCard disapear from my BB8100. If my program is still run, I connect my BB8100 to may computer and the SD is not accesible. When I end my program, the SDcard comes again.

 

Same effect in the debug. But in the debug I can execute 13 times leer_reglas until the SD disapear...

 

A problem of memory ? 

 

I's a crazy... help me, plz. Thx.

 

Message Edited by topo_topo on 01-16-2009 04:00 PM
Highlighted
New Developer
Posts: 9
Registered: ‎12-30-2008
My Device: Not Specified

Re: Strange... SDcard disapears after the 8th execution...

I have the solution... i never close the InputStream.

 

I omit the:

 

is.close();

 

Excuse me. Problem solved...