private void copyAsset()
{
if(Globals.hasStorage())
{
new Thread(new Runnable()
{
@Override
public void run()
{
AssetManager am = MainActivity.this.getAssets();
String srcPath = "Rose";
String desPath = Environment.getExternalStorageDirect
ory().getAbsolutePath();
copyFile(am, srcPath, desPath);
}
}).start();
}
}
public void copyFile(AssetManager am, String resPath, String desPath)
{
// ᅤᅰ, ᄆᆪᅱ나ᄋᄒ쎠ᅦᅮᄃ샤
if (resPath != null && !resPath.equals(""))
{
if(isFile(resPath))
{
//copy
try
}else
{
//continue
File file = null;
String path = desPath + File.separator + resPath;
file = new File(path);
if (file != null && !file.exists())
{
file.mkdirs();
}
// try
//
{
//
Runtime.getRuntime().exec("chmod 777 " + path);
//
} catch (Exception e1)
//
{
//
}
// ᄏ괘ᅣᄐ�ᄡᄀ
try
{
copyFile(am, resPath + File.separator + f, desPath);
}
}
}
}
public void copy(AssetManager am, String src, String des) throws Exception
{
String path = des + File.separator + src;
File file = new File(path);
if (file != null && !file.exists())
{
file.createNewFile();
}
// try
//
{
//
Runtime.getRuntime().exec("chmod 777 " + path);
//
} catch (Exception e1)
//
{
//
}
InputStream input = am.open(src);
FileOutputStream fileOutput = new FileOutputStream(file);
int count = -1;
byte[] data = new byte[1024];
while ((count = input.read(data, 0, 1024)) != -1)
{
fileOutput.write(data, 0, count);
}
input.close();
fileOutput.close();
file = null;
}
public boolean isFile(String path)
{
boolean result = false;
if(path != null && !path.equals(""))
{
result = path.lastIndexOf(".") > 0;
}
return result;
}