android - GAE Reading from Datastore -


i want return myhighscores datastore: i.e.: paul,1200 tom,1000 kevin,800

private void returnhighscores(httpservletresponse resp, string game, int max) throws ioexception {     datastoreservice datastore = datastoreservicefactory.getdatastoreservice();     key gamekey = keyfactory.createkey("game", game);     query query = new query("highscore", gamekey);     query.addsort("points", query.sortdirection.descending);     list<entity> highscores = datastore.prepare(query).aslist(fetchoptions.builder.withlimit(max));      for(entity e : highscores) {         resp.getwriter().println(e.getproperty("name") + "," + e.getproperty("points"));     } } 

and working :) ! when want read returned highscores , add string textview with:

androidhttpclient client = androidhttpclient.newinstance("mueckenfang");         httppost request = new httppost(highscore_server_base_url + "?game=" + highscoreserver_game_id);          httpresponse response = client.execute(request);         httpentity entity = response.getentity();         inputstreamreader reader = new inputstreamreader(entity.getcontent(), "utf-8");         int c = reader.read();         while (c > 0) {              highscores += (char) c;             c = reader.read();         }         textview tv = (textview) findviewbyid(r.id.highscoretv);         tv.settext(highscores); 

i html code like:

><html><head><meta http-euiv="content-type"content="text/html;charset=utf-8"><title>405 gttp method post is....

but want paul,1200 tom,1000 kevin 800 , on

httppost not accepted query parameter, "?game=" + highscoreserver_game_id.

you need pass values

androidhttpclient client = androidhttpclient.newinstance("mueckenfang"); httppost request = new httppost(highscore_server_base_url); list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(1);   namevaluepairs.add(new basicnamevaluepair("game", string.valueof(highscoreserver_game_id)));     request.setentity(new urlencodedformentity(namevaluepairs));  httpresponse response = client.execute(request); httpentity entity = response.getentity(); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -