I'm trying to list files from two different directories in an Android device in order to upload them to a server.
To do that, I'm getting the directory files under a File type and then throwing both listFiles() into correspondents File[] types.
String d1 = Environment.getExternalStorageDirectory().getPath()+"/Download/";
String d2 = Environment.getExternalStorageDirectory().getPath()+"/DCIM/Camera";
File DirDocuments = new File(d1);
File DirCamera = new File(d2);
File[] ListDocuments = DirDocuments.listFiles();
File[] ListCamera = DirCamera.listFiles();
I've tryed to merge then and uploadign using just a single "for" loop
List<String> listTemp = new ArrayList<String>();
for( int i=0; i< ListaDocuments.length; i++)
{
listTemp.add( ListaDocuments[i].getName() );
}
for( int i=0; i< ListaCamera.length; i++)
{
listTemp.add( ListaCamera[i].getName() );
}
File[] DirTotal = (String[]) listTemp.toArray(); //toArray gives Object[] and cannot be converted to File[], so I used String[]
But my app just stop and exits. What am I doing wrong?
Do anyone knows how can I merge ListDocuments and ListCamera into a single File[]?
Thanks in advance. (sorry about my typos and bad english)