How to show one time message/dialog in sketchware

One time message or one time dialog is a simple task for sketchware that every new coder find difficult to implement in sketchware. This task can easily be done by use of shared preferences and it do not require any external codes or blocks.


What is shared preferences 

It is a component of sketchware that is used to store strings database in app data. The files made by shared preferences is not stored locally in internal storage of device. Shared preferences can store any type of strings and that is what we are going to use in sketchware today.





Making one time appear dialog 

Follow these steps to make one time appear dialog in sketchware.

  1. Go to your project
  2. Go to component manager
  3. Click on + icon and choose shared preferences
  4. name it "sp"
  5. When user click on any button or something put data key show to no
  6. In oncreate, add an if-then-else condition and check if sp get key show equals blank then show dialog else don't show dialog.




You can name anything to these variables but don't try to access invalid file ( for example if you set the file as show and if you try to access it with another name then it will lead your app to crash.)


How to reset shared preferences 


For example if you're testing your app and you set your shared prefrence file then whenever you open your app you'll see that app already shown data for first time and not show again. 

Maybe you not understand the condition but here is a tip from me " Whenever you want to reset your shared preferences do not uninstall the app, just go to app settings and clear cache and storage. This operation will automatically reset all shared preferences.



Thanks for reading this post and as always if you got any problem then we're ready to help you in our discussion group.

Comments

Popular posts from this blog

Sketchware Generate Firebase Dynamic Link (Long Url To Short) | sketchware blocks explained

what is sketchware and history of sketchware

How to import local library in sketchware

Create HTML Dialog in Sketchware

Create Percentage loading bar in sketchware

how to import export custom blocks sketchware

Sketchware Generate Firebase Dynamic Link (Long Url To Short) | sketchware blocks explained

Android 10/11 Storage Permission sketchware | New blocks + method

Auto Get text from camera || OCR in sketchware || free project | Sketchware pro tutorial

Image filter moreblocks for making black and white imageview