I’m buiding an app that what it does is scan the root folder

and then it searches if there is any folder inside… the purpose of this is to save all the
text files routes in database..the database will contain the textfile name and the route.
this is part of the code:
private void seedData(int indent, File file) throws IOException {
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++)
{
seedData(indent + 4, files[i]);
path+=files[i].getPath();
}
}
else{
db.execSQL("insert into "+TABLE+" (title, url) values ('"+
file.getName().substring(0, file.getName().length()-4)+"', '"+file.getPath()+"');");
}
}
but in normal Java I just create a File with the route and then send it to the method like
this: seedData(1, new File("/root")); .So my question is, how do I do this in Android? or to be more precise, how do I create a file that points to the root folder that is located in assets so it gets “scanned” by my code. I already tried seedData(1, new File("/assets/root")); but it just didnt work.
Any help would be much appreciated.
Note: No, I cannot save the paths manually since there is over 3k text files in all those subfolders.
The problem here is that the assets are not files. The Android equivalent of your above method would be something like this:
You would call this from your Activity with
For reference, the URI format for assets in the “root” folder is
file:///android_asset/root/....