android - How to automatically save and load user input kivy -


i making app there profile screen in can enter generic profile information (name, height, weight, ect..) using textinput boxes. know there way put button next each textinput box save information , button load information. wondering if there way automatically load information when user opens app rather manually loading information hitting button. have suggested ussing subclass of configparser parse standard ini files , use load app-specific settings, have no idea how this.

kivy file:

<phone>: result: _result h: _h w: _w   anchorlayout:     anchor_x: 'center'     anchor_y: 'top'      screenmanager:         size_hint: 1, .9         id: _screen_manager         screen:             name: 'home'             canvas.before:                 rectangle:                     pos: self.pos                     size: self.size                     source: "/home/aaron/desktop/main.png"             label:                 markup: true                 text: '[size=100][color=ff3333]welcome [color=ff3333]diabetes manager[/color][/size]'         screen:             name: 'menu'             gridlayout:                  cols: 2                 padding: 50                 canvas.before:                     rectangle:                         pos: self.pos                         size: self.size                         source: "/home/aaron/desktop/main.png"                  button:                     text: 'my profile'                     on_press: _screen_manager.current = 'profile'                  button:                     text: 'history'                     on_press: _screen_manager.current = 'history'                       button:                     text: 'new entry'                     on_press: _screen_manager.current = 'new_entry'                  button:                     text: 'graph'                     on_press: _screen_manager.current = 'graph'                  button:                     text: 'diet'                     on_press: _screen_manager.current = 'diet'                  button:                     text: 'settings'                     on_press: _screen_manager.current = 'settings'           screen:             name: 'profile'             gridlayout:                  cols: 1                 boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]name[/color][/size]'                     textinput:                         id: _name                         hint_text: 'name'                  boxlayout:                     label:                           size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]gender[/color][/size]'                     textinput:                         id: _gender1                         hint_text: 'gender'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=34][color=0000ff]type of diabetes[/color][/size]'                     textinput:                         id: _type                         hint_text: 'type of diabetes'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]height (in)[/color][/size]'                     textinput:                         id: _h                         hint_text: 'height in inches'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]weight (lb)[/color][/size]'                     textinput:                         id: _w                         hint_text: 'weight in pounds'                  boxlayout:                     button:                         text: 'calculate bmi'                         on_press: root.product(*args)                      label:                         size_hint_x: 4.5                         id:_result                         bold: true                         markup: true                         text: '[size=40][color=0000ff]bmi[/color][/size]'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=30][color=0000ff]list of medications[/color][/size]'                     textinput:                         id: _meds                         hint_text: 'list of medications'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=38][color=0000ff]insulin times[/color][/size]'                     textinput:                         id: _times                         hint_text: 'please enter times take insulin'           screen:             name: 'history'             gridlayout:                  cols:1          screen:             name: 'new_entry'             gridlayout:                 cols:1                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]time[/color][/size]'                     textinput:                         id: _time                         hint_text: 'current time'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=28][color=0000ff]blood sugar (mg/dl)[/color][/size]'                     textinput:                         id: _glucose_reading                         hint_text: 'current blood sugar'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=40][color=0000ff]carbs[/color][/size]'                     textinput:                         id: _food                         hint_text: 'total carbs meal'                  boxlayout:                     label:                         size_hint_x: 0.22                         bold: true                         markup: true                         text: '[size=30][color=0000ff]medications taken[/color][/size]'                     textinput:                         id: _meds_taken                         hint_text: 'please enter medications taken'           screen:             name: 'graph'             gridlayout:                  cols: 3                 padding: 50             label:                  markup: true                 text: '[size=24][color=dd88ff]your graph[/color][/size]'          screen:             name: 'diet'             gridlayout:                  cols: 3                 padding: 50             label:                  markup: true                 text: '[size=24][color=dd88ff]reccomended diet[/color][/size]'           screen:             name: 'settings'             gridlayout:                  cols: 3                 padding: 50             label:                  markup: true                 text: '[size=24][color=dd88ff]settings[/color][/size]'   anchorlayout:     anchor_x: 'center'     anchor_y: 'bottom'     boxlayout:         orientation: 'horizontal'         size_hint: 1, .1         button:             id: btnexit             text: 'exit'             on_press: app.stop()          button:             text: 'menu'             on_press: _screen_manager.current = 'menu' 

kivy has storage functionality inbuilt. using inbuilt methods store file in correct place android or ios without having worry correct location. here's docs: https://kivy.org/docs/api-kivy.storage.html#module-kivy.storage

and short example show how put, retrieve , delete values:

from kivy.storage.jsonstore import jsonstore  store = jsonstore('baz.json') store.put('foo', 'bar')  if store.exists('foo'):     print('foo is:', store.get('foo'))     store.delete('foo') 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -