Android Question database sul server

SalentoFC

Member
Licensed User
Longtime User
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!
 

SalentoFC

Member
Licensed User
Longtime User
I found it on forum b4

Fixing Order in a Map --------------------- Dim mapCopy As Map mapCopy.Initialize ' add empty elements to fix their order in the map mapCopy.Put("Item #1", "") mapCopy.Put("Item #2", "") ' now read elements from file mapCopy = File.ReadMap2(File.DirInternal, "settings.txt", mapCopy)

What's utility of readmap2? Can permite to order a txt file as I understood?
Can be util for me?

-------------------
Readmap2 permette di ordinare un file txt a quanto ho capito? Come potrei usarlo nel mio caso senza dover inserire il txt in un db solo x fare l'ordinamento?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Dunque... eseguite provette, tutto ok, fino a quando mi sono scontrato contro un muro.

L'idea era che l'utente giocatore, completato il proprio giochetto, scaricasse un normale file di testo tramite FTP, lo cancellasse momentaneamente dal server, giusto il tempo per inserire il proprio punteggio, se compreso tra i primi x, e lo ricaricasse sul server.

Quando avevo già tutto pronto, mi sono reso conto che il file potrebbe sparire definitivamente se l'utente, volontariamente o per problemi tecnici, non effettuasse nuovamente l'upload del file-classifica.

A questo punto dovrebbe intervernire il server, in qualche modo.

Non ho ancora la soluzione per questo; spero di trovarla presto, perché ho messo troppa carne sul fuoco e non ho mille teste come Erel, ma solo mezza :p

-------------------------------------------

The idea was: a user, completed his game on the device, downloads the ranking file, deletes it from the server (to avoid conflicts with other users), adds his score and uploads the file again.

Hitch: if the user, voluntarily or involuntarily, does not reloads the file on the server?

The server should, in some way, restore that file.

For the moment I do not have a solution for this; I suppose the need of some JQuery instruction (PeriodicalUpdater?).


Any suggestions would be appreciated.


Thanks.
 
Last edited:
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
Excuse me for the later reply but i'm working about it.
I'm trying the list about text file but there's a problem about the type.
when i insert values and add it.into the list the result of file.readlist is that broke the result into 3 lines and not only one.
attach the project to unaerstand
 

Attachments

  • LISTA.zip
    87.9 KB · Views: 350
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I state that I can not run your project (B4A 3.0) and that the file prova.sfc is currently empty.

You want to use List for sorting, otherwise you could use Maps.

However, you can use:
B4X:
Dim sb As StringBuilder
sb.Initialize
sb.Append(Persona.ID)
sb.Append(Persona.NomeUtente & ",")
sb.Append(Persona.Punteggio & ",")
sb.Append(Persona.TempoImp & ",")
sb.Append(Persona.Livello & ",")
sb.Append(Persona.Data & CRLF)

Persons.add(sb.ToString)
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
Not work again. With your code is been created a single line but now there's this error at the order

NoSuchFieldException (ID)

The string is (1 Gioc,1000,30'',1,09/12/2014)
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
I've resolved it whit sort and no sorttype. I put punteggio field first at the append line and seems work. Now I must to see how to indicate at the user his point because I don't know if can do a search into a list
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
How can I get different values of persons (list).where there are various fields? If I do Persons.Get (1) result is all the fields as a single line.
But I need to divide result in different fields as it is composed.
tks
 
Last edited:
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
Quasi riuscito Luca.
sto provando con le map
posso ordinare una mappa per campo (punteggio nel mio caso)
Ti allego progetto

A few moment at the end
I'm trying with map file
Can I ordinate a file map for a determinate value (field)
I attach here project
 

Attachments

  • P.zip
    88.3 KB · Views: 381
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
No, you can't.

When you write an object variable name, you can see methods and properies right after the dot:

upload_2014-12-10_1-26-53.png


As you can see, there is not Sort.

Also, there is a pair of nice pdf manuals :mad: :)

I can not run your project! (2)

And I'm lost: your problem was sorting data or sharing data on Internet?

Anyway, you should use an Array of Int as index (pointer) for the map data, sorting it (the array) using some sorting routine, like QuickSort or BubbleSort...
You can find these routines on this site or on Web.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You have at least four solutions, for sorting. I list them in order from worst to best.

1) the solution that I have already indicated, use a sortin routine, from which you can get an index or an ordered map;

2) use a SQLite DB, filling its table with the data of the map, ordering the table using a query and get the ordered map from the table;

3) use directly a SQLite DB instead of a Map;

4) as above, but also using the Table class and its LoadSQLiteDB routine.
 
Upvote 0

SalentoFC

Member
Licensed User
Longtime User
I think too a txt can be sufficient and not have problems with upload .
Now remaining to sort dates for publish results on device's display but probably can use solution you indicate above (Regex.Split).
At the end, if you have got, I like to donate you for your really help at the problem ok? ;-)
P.S. Where are you from?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
why do you stick to this retarded method?

the coding logic is far from what it should be that's why you have all that misery.
 
Upvote 0
Top