I'm trying to understand how to work with files in Android
I have installed my android application in external storage
it contain a folder data
of files that it need while running...
firstly I think that my folder will saved automatically in the sdcard while installing
but after reading some question here , It seem I should create a folder in which I save my
folder data
...
I write this question to ask about steps to do to achieve my goal an I need your advances
Goal
- Save a folder
data
in external storage , read from it and write a new file
Steps
add permission to manifest file
create a folder in sdcard ==> how to place my folder there ?
create a new file , save it on sdcard and write into it
code
This is a part of my activity :
{
....
File file = new File ("...")
doPrediction(file);
}
private void doPrediction (String FileName)
{
for (File child : VisualModels.listFiles()) {
svmPredict.run(MyDataSource.inputPrediction,
new File( MyDataSource.outputPrediction+ "/"+child.getName()+".predict"),
child);
}
}
I declared the class svmPredict
as any ordinary java class ans this is the code of run method
try
{
BufferedReader input = new BufferedReader(new FileReader(inputFile));
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)));
svm_model model = new svm().svm_load_model(modelFile);
if(predict_probability == 1)
{
if(svm.svm_check_probability_model(model)==0)
{
System.err.print("Model does not support probabiliy estimates\n");
System.exit(1);
}
}
else
{
if(svm.svm_check_probability_model(model)!=0)
{
svm_predict.info("Model supports probability estimates, but disabled in prediction.\n");
}
}
predict(input,output,model,predict_probability);
input.close();
output.close();
}