Jump to content

[Resolvido] Android - Limpar Conteúdo Json


Recommended Posts

Boas pessoal.

Eu tenho um objecto json que está acessível em toda a Activity:

JSONObject obj = new JSONObject();   // JSON Principal

este objecto é composto por um objecto chamado Dados e um array de objectos:

dados.put("nome", nome);			   // objecto dados
obj.put("Dados", dados);				 // Coloco objecto de dados dentro o objecto principal

coordsObj.put( "lat", latvalue );	  //objecto coords que vai ser colocado dentro de um JSONARRAY
coords.put( coordsObj );			   // JSONARRAY que contem os objectos coordsObj

obj.put( "Coordnadas", coords ); // Coloco o array de coordnadas dentro o objecto principal,

o que queria fazer era colocar um butao e ao clicar nele apagava o JSONObject obj. tenho o butao ae tudo a funcionar so que clico nele e nao apaga, já tentei de varias maneiras sem sucesso :S.

O que me recomendam para apagar?

Link to post
Share on other sites
KTachyon

O que estás a fazer para apagar?

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to post
Share on other sites
KTachyon

E se fizeres:

obj = new JSONObject();

“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

-- Tony Hoare

Link to post
Share on other sites

ja descobri o problema, essa maneira funcionava, so que estava a esquecer-me de fazer o mesmo ao array, os valores de obj estavam limpos, so que quando punha valores no array e o enviava para o obj os antigos do array ainda la estavem,

obrigado

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.