简体   繁体   中英

how to make a directory structure for saving files in android?

i have a tree of objects and i want to make a directory file structure like the tree to download and save my files in external storage but i didn't know how to do this in android. please help. the tree like this json:

{"courses":[{"id":"1",
"name":"example1",
chapters:
[{"id":"1","name":"chapter1",pdf:[{"id":1,"link":"pdf link"}]}]}

and i want to save my pdf files on structure directory like appName/courses/course_name/chapter_name/pdf how to make this in android?

File dir = getExternalFilesDir("appName/courses/course_name/chapter_name/pdf ");

if ( ! dir.exists())
   if (! dir.mkdirs())
      {
      Toast( "Could not make directory " + dir.getAbsolutePath());
      return;
      } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM