Android Tutorial

Showing posts with label assest. Show all posts
Showing posts with label assest. Show all posts

12.27.2011

Copy file from assets to app in android



/**********************************
*
* Copy List file from folder if fileName != null : copy file of folderName
* if folderName == null: copy file of folder root assets else if folderName
* == null : copy all file of folder root assets
*
*
* *********************************/
private void copyFileFromAssetsToApp(String folderName, String fileName,
String folderNameInApp, String fileNameInApp, Context Ctx) {
Log.d(TAG, "copyClipart start");
AssetManager assetManager = getResources().getAssets();
final String root_dir = "/data/data/" + Ctx.getPackageName();
String basepath = root_dir + "/" + folderNameInApp;
if (Utils.checkNullOrEmpty(folderNameInApp)) {
basepath = root_dir;
}
File clipartdir = new File(basepath);
if (!clipartdir.exists()) {
clipartdir.mkdirs();
}