Sachin Gurnani
Sachin Gurnani

Reputation: 2444

How to pass json array from one activity to another and display it in a listview android

JSON responce is

{"DbList":[{"DataBaseName":"BRISBANE","UserID":"1","WebAdmin":true},{"DataBaseName":"CENTRES","UserID":"100001","WebAdmin":true},{"DataBaseName":"MEL","UserID":"1","WebAdmin":true},{"DataBaseName":"NSW","UserID":"10001","WebAdmin":true},{"DataBaseName":"OPERATORS","UserID":"1","WebAdmin":true},{"DataBaseName":"TEST","UserID":"1","WebAdmin":true},{"DataBaseName":"WA","UserID":"1","WebAdmin":true}]}

i want to print on database names in another activity in listview plz help Thanks in advance

Upvotes: 1

Views: 1468

Answers (1)

Lalit Poptani
Lalit Poptani

Reputation: 67296

JSON response is already in String format so you can just pass it to the next Activity as you are passing String to the next Activity using intent.putExtra("JSON", response.toString());. Then you can just get the values on the next Activity and display them.

To display data in the ListView just fetch the data from JSON response and add them to ArrayList<String> and just bind the ArrayList with the Adapter of the ListView.

Upvotes: 2

Related Questions