-1
嗨im仍然是新手在android编程。我想知道如何在android代码中读取像“/home/emulator/0/blabla/file.txt/”这样的文件路径。我需要知道如何读取文件路径,因为我必须从应用程序访问android上的特定文件。并且路径已经在代码中定义了,所以用户只会得到读数的输出。阅读文件路径android studio
public void naivebayes() throws Exception {
//im using weka to read a .arff file
//the problem is i didnt know how to "write" the path, from where i should start it
//p.s: i already tried open the files on my phone then clikc "Details" to see the path on the phone and write it on the code but the code still could'nt read the files
DataSource source = new DataSource("File Path");
Instances dataset = source.getDataSet();
//set class index to the last Attributes
dataset.setClassIndex(dataset.numAttributes()-1);
//create and build the classifier
NaiveBayes nb = new NaiveBayes();
nb.buildClassifier(dataset);
tv.setText(nb.getCapabilities().toString());
}
所以基本上,我必须在把我的文件模拟器? –