coolcool1994
coolcool1994

Reputation: 3804

How to create a folder inside a folder

So I created a folder in the internal storage like this:

File folder1 = getBaseContext().getDir("DataBase", Context.MODE_PRIVATE); //Creating an internal dir;

Now how to I create a new folder inside that folder1?

I tried this (below), but this creates a file and not a folder. . .

File insideFolder = new File (folder1,"Important Database");

I also tried calling mkdir but it seems like insideFolder is still a file.

Upvotes: 2

Views: 1825

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006574

Now how to I create a new folder inside that folder1?

new File(folder1, "subdirname").mkdir();

Now how to I create a new folder inside that folder1?

If the file was already there due to some previous experiment of yours, mkdir() will not delete it. You will need to delete it yourself.

Upvotes: 4

Related Questions