Salve a tutti.
Volevo sapere come fare ad aggiornare un file .db esistente sul server. È un file di classifica per gioco. Io scarico il file con ftp.download... poi il file che ho scaricato lo popolo con i miei dati e all'atto di effettuare l'upload sul server non mi da errori ma noto dal file di log "java.net.unknownhostexception: ftp.... etc cioè non riconosce il nome del server immagino. Cosa devo fare? Sto impazzendo.. grazie a tutti!
Yes it's strange infact..
if you like to prove the db is avaible at robertodaniele.altervista.org/sMg/sMg_21hz133.db
ps i tried it throw android emulator and no too with real device.
my scope is to download db, popolated it with news datas and upload the final file on server. But, repeat, the error is about name of server (unknownhostexception: ftp.robertodaniele.altervista.org
mServerAddr = "robertodaniele.altervista.org"
mFTPServerUserFolder = "/sMg/"
If FirstTime Then
FTP.Initialize("FTP", mServerAddr, 21, "robertodaniele", "curbikegko33")
End If
FTP.DownloadFile(File.Combine(mFTPServerUserFolder,"sMg_21hz133.db"), False, File.DirRootExternal, "sMg_21hz133.db")
mServerAddr = "robertodaniele.altervista.org"
mFTPServerUserFolder = "/sMg/"
If FirstTime Then
FTP.Initialize("FTP", mServerAddr, 21, "robertodaniele", "curbikegko33")
End If
FTP.DownloadFile(File.Combine(mFTPServerUserFolder,"sMg_21hz133.db"), False, File.DirRootExternal, "sMg_21hz133.db")
I'll attach here the code.
the scope is:
1. Download db from server and using it insert into a record;
2. Show it on device throw sub fillscrollview2 and delete record if count > 1000
3. Upload on server db and delete local file.
error: no such table..
I've correctly created db with sqlite manager db browser and upload it on my server.
what's the problem? Why not work?
I've got a week to finish this app. Pls help as you can.
tks.
The error is that you try to open the db immediately after starting the download, then the file is not Already available.
You should "wait" for the Sub FTP_DownloadCompleted event (open the db there).
B4X:
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success Then
Try
SQL1.Initialize(File.DirDefaultExternal, "sMg_21hz133.db", False)
Catch
Log("Error opening the db")
End Try
FillSimpleData
LogTable1
Log("Number of rows = " & SQL1.ExecQuerySingleResult("SELECT count(*) FROM table1 ORDER BY Punteggio DESC"))
Else
Log(LastException.Message)
End If
End Sub
This is a prove. I don't know how much is the time for the user to download the online classifice and I think that 1000 should be more than sufficient.
when i try project on my emulator b4a sub routine ftp_downloadcompleted never started after command ftp.downloadfile.. It's normal?
Now should be working? Have you try if work ok with emulator?
Ps i've thinking to use a txt file but is very complicated to ordinate each single line throw punteggio field..
Yes I know.. but in a txt the lines are not immediatly ordinate and then I must to insert two for cicles (the scolastic for I= 0 to n-1 and into a second for j = i+1 to n for ordinate the lines.
With db is a unic command order by
Then I'd like to use db for a question of logic.
ps I've got edge signal connection in my housr and not know if it is the problem about downloadcompleted not started