开发者

uploading scores to a text file

I am developing the scores part of a blackberry 开发者_运维知识库game.The scores are generated and I want to take username as input and display his resp score. How can I retrieve the scores in the text file?I am using text file as the db. the Updation is a problem and I have no clue how to go ahead with it.As many of u know, BB supports only few of Java APIs so please help me how to store and display player's name and score as and when new player plays the game.


Okay, you could store the scores in a text file and then retrieve the scores later. However, BlackBerry provides other classes for saving data that would probably work better for what you want to do. I would recommend you put the scores into a Hashtable and then store that hashtable with the PersistentStore class. The code to do that would look something like this:

Hashtable scoresTable = new HashTable();
PersistentObject perstObj = PersistentStore.getPersistentObject(<UNIQUE KEY>);
perstObj.setContents(scoresTable);
perstObj.commit();

If you really want a text file then the code to open it would look like this:

FileConnection fileConn = (FileConnection) Connector.open(<FILE URL>);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜