Pedometer starts counting from 1 every time the app is restarted, I use tinydb too

[mod edit - please post images to the community]


this is the code line

So basically I want to set the pedometer score to keep the previous score and continue it every time I open the application.


Perhaps Save() It saves the pedometer state to the phone. Permits permits accumulation of steps and distance between invocations of an App that uses the pedometer. Different Apps will have their own saved state.

I suspect that unless you Save, the pedometer will always start at 1 steps.

from Pedometer

so what should I do?

as I said I use tinydb and there is a save button, every time I click it saves the screen but if I move my phone (so basically I start the pedometer) it starts from 1 again

:cry: Don't do that! Instead use the tool that is part of the component call Pedometer1.Save

The tool's documentation is somewhat ambiguous. How to save steps from one use of the app to the next is shown here.

Does this technique work for you? If you want, you can also save the steps to the TinyDB as a record.

When you Save, the pedometer counter will start where you left off :slight_smile: .

1 Like

It didn't work :frowning:

what didn't work? Saving to TinyDB or saving the count so that when you close and reopen the app the app 'remembers' the previous count. The example code shows how to save the count without the TinyDB.

The code works on an Android 8.1. What do your Blocks look like?

Is anyone else who tried this having difficulty?

I did the same code in a new project as you did.

not same . The example uses a TextBox and a Label; your code does not.

can you show the design?

PedometerSimple.aia (2.9 KB)

Try this and experiment with the controls.

Thanks it worked!
By the way how can I hide the textbox square?

TextBox1.Visible = false

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps

How to do a lot of basic things with App Inventor are described here: How do you...? .

Also look here App inventor español. Offline. Tutorial. Ejemplos. Instalación. Códigos. Juegos. Curso gratis de App inventor. and here Tutorial Index | Imagnity for more tutorials

Learn about components Component Reference
and visit the Library The MIT App Inventor Library: Documentation & Support Help>Library on the MENU

Yaay it worked! Thaaanks:D

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.