I have two datasets which are currently in the same folder as my java files AND on my PC. Currently, I am accessing them through my C-drive. Since this is an app, where should I save my .ARFF files and what path should I use instead? I have tried in the raw folder, but nothing seems to work.
After too many hours
A very easy solution to retrieving data from the assets folder! Only one user-defined method.
raw
folder in res
directory.raw directory
.java
fileAppCompatActivity
A. This is in the main
function OR in a custom, user-defined
function.
BufferedReader bReader;
bReader = new BufferedReader(
new InputStreamReader(ISR(R.raw.FILENAME_WITHOUT_TYPE)));
FILENAME_WITHOUT_TYPE
refers to only the name of the file, not its ending (everything followed by the .).
B. This is the definition of ISR.
public InputStream ISR(int resourceId) {
InputStream iStream = getBaseContext().getResources().openRawResource(resourceId);
return iStream;
}
Works like a charm!
Resources: