重命名Sdcard内的目录:Android Worklight

时间:2013-11-21 07:07:26

标签: android ibm-mobilefirst

我想重命名“sdcard / XYZ_APP / images /”“images”文件夹中的文件夹,其中包含其中的所有图像。我想将“images”文件夹重命名为“.images”,如“mnt / sdcard / XYZ_APP / .images / ..”那么我们如何才能在android worklight中使用javascript进行操作?我尝试下面的代码,但我确信我的代码有问题。请查看此内容。

 function renamefile(){

var entry="sdcard/LMS_APP/images";
  DirectoryEntry Entry = new DirectoryEntry({fullPath: entry});
var parent = "sdcard/LMS_APP/";
DirectoryEntry  parentEntry = new DirectoryEntry({fullPath: parent});
 // move the file to a new directory and rename it
   Entry.moveTo(parentEntry, ".images", success, fail);

}

1 个答案:

答案 0 :(得分:1)

这段代码适合我

/* Move /sdcard/Songs to /sdcard/Songs123 */
function renamefile(){
    var from = new DirectoryEntry("Songs", "/sdcard/Songs"); 
var  to =  new DirectoryEntry("Songs123", "/sdcard");
from.moveTo(to, "Songs123", success, failure);
}

所以,试试这些行

function renamefile(){
    var from = new DirectoryEntry("images", "/sdcard/LMS_APP/images"); 
    var  to =  new DirectoryEntry(".images", "/sdcard/LMS_APP");
    from.moveTo(to, ".images", success, failure);
}