Coders Packet

Read data from Google sheets into an Android app in Java

By Deeksha R

This project reads data from google sheets in from of json object and data can be displayed and modified.

Google sheet can be used as the database for an android app. This project reads data in form of JSON objects and displays it. 

The spreadsheet that is used in this project is a list displaying the student id, student name, and the marks

The steps involved:

  1. Add volley implementation into the Gradle build file. Please refer: https://developer.android.com/training/volley

  2.Add the users' permission to allow network connection.

  3.Code the XML part.I have included two buttons: READ and TRIGGER.

     *The read button on clicking will take the user to an activity that displays the contents of the spreadsheet.

     *The Trigger button on clicking will take the user to an activity that displays the result corresponding to each student. The result is decided based on marks. 

      * There is an XML file for displaying the list(RecyclerView) and for every element in the list.

  4 . The java code consists of mainActivity, Read and Trigger.

      -> The main activity has Read and Trigger buttons that lead to the corresponding activities.

     ->The Read activity sends a volley request and obtains data in form of a JSON object. The data is then extracted from the JSON object and displayed on the screen. To send volley request please refer: https://developer.android.com/training/volley/simple

The URL used must be of the form: https://spreadsheets.google.com/feeds/list/spreadsheetid/od6/public/values?alt=json

where the spreadsheetid is obtained from the spreadsheet URL.

  ->The Trigger activity along with displaying the content displays the result i.e Pass or Fail. The result is based on a conditional statement.

If the marks obtained are greater than 40 the result is pass else fail.

 

Screenshots:

 

 

 

 

 

 

Download project

Reviews Report

Submitted by Deeksha R (deeksha)

Download packets of source code on Coders Packet