is there a way to put entire folder from "assets"

All your problems with Audio, Video and Images.

is there a way to put entire folder from "assets"

Postby aspidoff » Thu Oct 08, 2009 12:22 pm

hey guys, i hope this is the right forum.

what i am trying to do is simply copy over entire folder full of mp3 files onto sdcard within an app. I am doing this out of "assets" folder because raw folder does not allow mp3 files to be named a certain way.

here is what I dug up so far but not sure if this will work. i am lost

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. InputStream ins = getResources().getAssets().open("");
  3.  
  4. int size = ins.available();
  5.  
  6. // Read the entire resource into a local byte buffer.
  7.  
  8. byte[] buffer = new byte[size];
  9.  
  10. ins.read(buffer);
  11.  
  12. ins.close();
  13.  
  14. FileOutputStream fos = new FileOutputStream("/sdcard/myfolder/");
  15.  
  16. fos.write(buffer);
  17.  
  18. fos.close();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


can someone help?
aspidoff
Freshman
Freshman
 
Posts: 3
Joined: Sun Aug 02, 2009 11:53 pm

Top

Postby azraeal » Thu Oct 08, 2009 6:03 pm

Have you actually tried this to see if it works?

Aside from suggesting to read small chunks at a time instead of the whole thing due to possible memory issues, and maybe to flush your streams before closing them, I don't see anything wrong with the logic.
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 13 guests