Well, I don’t know, how I did it, but the folowing code works:
import processing.sound.*;
String filePath = "/sdcard/Sketchbook/VisualizerProject/data/song.mp3";
void setup(){
stealFile(filePath, "song.mp3");
SoundFile sf = new SoundFile(this, /*dataPath("song.mp3")*/filePath);
sf.play();
}
void draw(){
background(0);
}
boolean stealFile(String from, String filename){
println("Stealing file \"" + from + "\"...");
if(!(new File(from).exists())){
println(" Fail: Input path invalid...");
return false;
}
BufferedReader reader;
PrintWriter writer;
try{reader = createReader(from);}
catch(Exception e){
println(" Fail: Reader couldn't be created...");
e.printStackTrace();
return false;
}
try{writer = createWriter(dataPath(filename));}
catch(Exception e){
println(" Fail: Writer couldn't be created...");
e.printStackTrace();
return false;
}
while(true){
String l;
try{l = reader.readLine();}
catch(Exception e){continue;}
if(l == null) break;
writer.println(l);
}
try{
reader.close();
}
catch(Exception e){
println("Reader couldn't be closed");
}
writer.flush();
writer.close();
println(" Success: File \"" + from + "\" succesfilly stolen and copied as \"" + filename + "\".");
return true;
}