Void copyAssets ()
{
String [] files;
Try
{
Files = this. getResources (). getAssets (). list ("");
}
Catch (IOException e1)
{
Return;
}
If (! MWorkingPath. exists ())
{
If (! MWorkingPath. mkdirs ())
{
New AlertDialog. Builder (this)
. SetTitle (R. string. ERROR)
. SetMessage (R. string. FAILED_DIR_CREATE)
. SetPositiveButton (android. R. string. OK, new OnClickListener (){
@ Override
Public void onClick (DialogInterface dialog, int which)
{
Dialog. dismiss ();
}
})
. Create ()
. Show ();
}
}
For (int I = 0; I <files. length; I ++)
{
Try
{
String fileName = files [I];
If (fileName. compareTo ("images") = 0 |
FileName. compareTo ("sounds") = 0 |
FileName. compareTo ("webkit") = 0)
{
Continue;
}
File outFile = new File (mWorkingPath, fileName );
If (outFile. exists () continue;
InputStream in = getAssets (). open (fileName );
OutputStream out = new FileOutputStream (outFile );
// Transfer bytes from in to out
Byte [] buf = new byte [1, 1024];
Int len;
While (len = in. read (buf)> 0)
{
Out. write (buf, 0, len );
}
In. close ();
Out. close ();
}
Catch (FileNotFoundException e)
{
E. printStackTrace ();
}
Catch (IOException e)
{
E. printStackTrace ();
}
}