Skip to content

Commit

Permalink
Added saving data to file
Browse files Browse the repository at this point in the history
  • Loading branch information
tainfante committed Sep 4, 2019
1 parent c83d59c commit 208ec1a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/example/rehabapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MainActivity : AppCompatActivity(), ComFragment.ComFragmentInterface, Conn
private lateinit var chronometer: Chronometer
private var connectedDevice = ConnectDevice(this, this)
private val queueHandler = QueueHandler()
private val saveToFile = SaveToFile(this)


private var bluetoothAdapter: BluetoothAdapter? = null
Expand Down Expand Up @@ -123,6 +124,8 @@ class MainActivity : AppCompatActivity(), ComFragment.ComFragmentInterface, Conn
override fun onStartButtonClicked() {
connectedDevice.macAddress=macaddress
connectedDevice.execute()
saveToFile.createFile("eloelo.txt")
saveToFile.saveToFile()

}

Expand Down
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/rehabapp/SaveToFile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.rehabapp

import android.content.Context
import java.io.File

class SaveToFile(val context: Context) {

private var file: File? = null
private var directory: File? = null

fun createFile(filename:String){

val path = context.getExternalFilesDir(null)
directory = File(path, "DATA")
val success = directory!!.mkdirs()
file = File(directory, filename)

}
fun saveToFile(){

file?.appendText("eloelo")

}
}

0 comments on commit 208ec1a

Please sign in to comment.