java


How to save the answers of radio buttons to a csv file or txt file on Android


Hello i searched a lot but i couldn't find an answer that solves my problem.My question is simple How to save the answers of radio buttons to a csv file or txt file on Android.
So i want when the user answer the question and clicks on save button it will create a csv file or txt file with the answer and save it on the device
My activity_main.xml is :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kyriakos.test.MainActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<TextView
android:id="#+id/textView3"
android:layout_width="377dp"
android:layout_height="47dp"
android:text="What is the slope of the field?"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="16dp"
tools:layout_constraintLeft_creator="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.0" />
<RadioGroup
android:layout_width="298dp"
android:layout_height="449dp"
tools:layout_editor_absoluteX="5dp"
tools:layout_editor_absoluteY="-29dp">
<RadioButton
android:id="#+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="93dp"
android:text="Low slope (0-5%) "
app:layout_constraintLeft_toLeftOf="#+id/textView3"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
<RadioButton
android:id="#+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="Medium slope (6-20%)"
app:layout_constraintLeft_toLeftOf="#+id/radioButton"
app:layout_constraintTop_toBottomOf="#+id/radioButton"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
<RadioButton
android:id="#+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:text="High slope (21-60%)"
app:layout_constraintLeft_toLeftOf="#+id/radioButton2"
app:layout_constraintTop_toBottomOf="#+id/radioButton2"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
<RadioButton
android:id="#+id/radioButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="29dp"
android:text="Very high slope (>60%)"
app:layout_constraintLeft_toLeftOf="#+id/radioButton3"
app:layout_constraintTop_toBottomOf="#+id/radioButton3"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1" />
</RadioGroup>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginBottom="40dp"
android:layout_marginEnd="50dp"
android:layout_marginLeft="51dp"
android:layout_marginRight="50dp"
android:layout_marginStart="51dp"
android:text="Save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintRight_toRightOf="parent"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintRight_creator="1" />
And the java class code is :
package com.example.kyriakos.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Question2 extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Thank you for the responses in advance!!

Related Links

Generating Random integers within a range to meet a percentile in java
Hide a Folder through java application
Should Hibernate Session#merge do an insert when receiving an entity with an ID?
What is the equivalent of stringByFoldingWithOptions:locale: in Java?
JScrollPane doesn't work properly
decimal formatting, adding the $ symbol
JavaFX - Action during event
Need aid with the code I wrote (need to understand)
How struts property tag works with date value?
How to decompress a file or folder in java?
INSERT INTO SELECT STATEMENT with multiple FK
NullPointerException in Jetty 6.x while deploying servlet from an external jar
simple calculator function in java [closed]
Recursive method with wrong parameter
do-while loop wont end and crashes program
Java - Make my unfilled arrays not print out null and 0?

Categories

HOME
layout
relayjs
alfresco
cvs
graphql
opengl-es-2.0
autotools
add
python-unittest
google-translate
quicklook
etl
windows-azure-storage
dtrace
carthage
jsprit
systemc
interop
sms-gateway
google-pagespeed
dbext
riot.js
sylius
tapestry
devops
p-value
h2db
smb
tasklet
flink-streaming
frame
iframe-resizer
webtest
openoffice.org
service-discovery
temporary-files
tasker
botbuilder
spring-security-kerberos
heightmap
businessworks
qcombobox
auto-update
hibernate-tools
dds
rails-routing
return-value
brightcove
setter
nodebb
font-size
sybase-asa
flutterwave
dynamics-sl
cubes
database-optimization
adxstudio-portals
underscore.js-templating
mikroc
ctest
merge-conflict-resolution
contact-list
apachebench
ptrace
spim
reactive-banana
sdhc
feedback
spidermonkey
fouc
purge
jqgrid-formatter
coveralls
event-bubbling
createprocessasuser
iiviewdeckcontroller
angular-local-storage
codeigniter-url
xcode-6.2
terminal-services
page-layout
gridfs
pygit2
html-editor
e4x
rdoc
cisco-jtapi
dotnethighcharts
assembly-loading
cufon
netdna-api
mercurial-server
window-management
hirefire
gcj
joyent
lang
dbal
multi-tier
eqatec
aquaticprime

Resources

Encrypt Message