Please help me... I have some problem with global variable

question

(K Mehandole) #1

Hello guys
Please check given blocks
I have some problem with Global variable number
When I click on done button in listview numbers count regularly like 1 2 3
And when I close app and again tried to click on done button numbers count Again start from 1 and 2

How to stop this nonsense

:point_right: i want numbar never repeat again & again


#2

Ok and what’s the problem?


(avmcreators02) #3

What’s the problem clear it


(Abhijith) #4

Use the Tiny DB Component and save the the last number as a value to a tag named previous number or anything and get the value via Tiny DB


(Deepanshu Arya) #5

If you store value in variable, Then they will be set to default every time you close app you must use tinydb to store values and call them


(K Mehandole) #6

Please check I describe now


(Deepanshu Arya) #7

U must use tinyDB component to store those value like 1,2,3,4 etc if you use global variable then when you close app it will delete all values from variable


(Cian O'Sullivan) #8

All of the answers are correct, so let me summarize.

  1. Global variables are volatile, meaning when the screen or application closes the contents are lost. They are not sticky.

  2. To have a variable be sticky across screens, or across application usage, you need to store that content/state somewhere. Examples include TinyDB, Files, firebase, etc.

Setup a procedure to

a) Write to the place holder (like TinyDB)
b) Read from the place holder
c) Error check if there is a problem.

Beware, TinyDB data is destroyed if someone uninstalls the application. You will need to store in another maner if you want the data to be sticky across devices, or installs.


(K Mehandole) #9

Please help me with set the blocks for me


(Deepanshu Arya) #10

Bro try it yourself first and ask if you face any problems, this will help you in learning more
Kodular is all about EXPLORING :wink:


(Cian O'Sullivan) #11

You have to decide how you want things stored. As @deepanshu_da85 said you gotta try things out. there are so many block examples and snippets around with a little bit of work you can find and do it.


(Abhijith) #12

How do you want the time to be taken? From online or from user’s device?

See this video it will help you get a basic knowledge about this


(K Mehandole) #13

Ty all my dear friends…


(Deepanshu Arya) #14

If u got your problem solved then tick the best answered as solution as it will help other on the same problem


(K Mehandole) #15

I don’t know about coding and don’t know how to solve this problem
I trying to solve but I didn’t get my solution