2012-03-04 26 views
0

我在文件夾「testFiles」中添加了一些文件到我的android應用程序。我還創建了(首次啓動時)在data/data /中具有相同名稱的空文件夾...下一步應該列出assets「testFiles」中包含的文件,然後將所有文件複製到應用程序數據創建的新文件夾中。我正在使用以下功能在iOS上執行相同的問題,請注意,僅發佈了objectiveC代碼以闡明所要求的內容。謝謝。android列表並將文件從assets文件夾複製到應用程序數據

- (void)copyResources:(NSString *)sourcePath: (NSString *)destPath { 

    NSArray* resContents = [[NSArray alloc] init]; 

    resContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:sourcePath error:NULL]; 

    for (NSString* obj in resContents){ 
     NSError* error; 
     if (![[NSFileManager defaultManager] copyItemAtPath:[sourcePath stringByAppendingPathComponent:obj] toPath:[destPath stringByAppendingPathComponent:obj] 
       error:&error]) 
      NSLog(@"Error en creació de directori: %@", error);; 
    } 
} 
+0

StackOverflow用於編程問題。這不是一個問題。 – CommonsWare 2012-03-04 21:59:28

+0

我的問題是用哪個函數列出文件夾中包含的所有文件... – Jaume 2012-03-05 08:07:47

回答

0

要使用資產,請使用AssetManager。要使用給定前綴(例如文件夾名稱)列出資產,請使用AssetManager上的list()方法。

+0

謝謝!那是我需要的 – Jaume 2012-03-05 17:22:04

相關問題