SOLUTION AT THE BOTTOM OF THE QUESTION
I have a FTP Server with more than 3'000 pictures on it and I save the picture names to an ArrayList. After this I'd like to save them from arraylist to database and that is taking very very very very much time! See:
With
FTPFile[] files = ftpClient.listFiles();
for (FTPFile file : files) {
imageNames.add(file.getName());
}
I get a list of all those files and save them into the ArrayList imageNames. This is very fast and don't take more than 1 - maximum 2 seconds.
Now I like to write this array backwards to my sqlite database. When I do this it takes extremly long to be finished! I waited more than 2 minutes for it...
int i = imageNames.size() - 1;
int q = 0;
while(i >= 0){
String insert_arraylist = "INSERT INTO ARRAYLIST (STRING) VALUES ('"+imageNames.get(q)+"')";
db.execSQL(insert_arraylist);
i--;
q++;
}
So how can I speed up this inserting??
Thanks in advance!
SOLUTION: (From more than 2 minutes to less than 3 seconds ;))
FTPFile[] files = ftpClient.listFiles();
insert_arraylist = "";
ContentValues con = new ContentValues();
for (FTPFile file : files) {
imageUrls.add("http://192.168.99.104/GetThePicture/thumbs/"+file.getName());
}
int i = imageUrls.size() - 1;
int q = 0;
db.beginTransaction();
try{
while(i >= 0){
String insert_arraylist = "INSERT INTO ARRAYLIST (STRING) VALUES ('"+imageUrls.get(q)+"')";
db.execSQL(insert_arraylist);
i--;
q++;
}
db.setTransactionSuccessful();
} catch(Exception e){
} finally {
db.endTransaction();
}