0

I have a class called SuperRecorder. I need this to create a folder "Test" with the sub folders "Touch", "Screen". Later on I will have to save stuff to these sub folders in other classes and I can't grasp how I would do this...

I understand I could make the folders within SuperRecorder with the

File recorder_dir = context.getDir("Test", Context.MODE_PRIVATE);
File touch_dir = new File(recorder_dir, "touch").mkdir();
File screen_dir = new File(recorder_dir, "screen").mkdir();

as described in: Creating directory in internal storage android

but I'm not sure how to get this path in the other subclasses.

I don't really understand the folder hierarchy in the internal storage. I'm writing my touch file to /data/data/com.testapp/app_touch (even though I specify the folder name as "tocuh"?) so I'm missing one level (should be /com.testapp/recording/app_touch) but when I try to use this folder (I want to zip it) I try to do the getFilesDir() but this will direct me to /data/data/com.testapp/files

I'm not really sure where I'm supposed to put my files and how I make sure everything is placed in the correct folder.

Help is appreciated!

Community
  • 1
  • 1
mnordber
  • 1,143
  • 2
  • 13
  • 18

1 Answers1

0

I would recommend using the files dir inside /data/data/com.testapp/ root.

In addition, you should use mkdirs() instead of mkdir() because the latter only creates one directory if the parent exists. You can create your folder structure like:

File recorder_dir = new File(context.getFilesDir(), "Test");
recorder_dir.mkdirs();
File touch_dir = new File(recorder_dir, "touch").mkdirs();
File screen_dir = new File(recorder_dir, "screen").mkdirs();

Hope it helps.

Junior Buckeridge
  • 2,075
  • 2
  • 21
  • 27