Creating block to get FirebaseDb data to Map

1. This post shows how to create a block to get FirebaseDb data to Map variable.

2. In Sketchware pro, in Settings, go to Block Manager.


3. Add new pallete 'New Firebase' and select color.

4. Inside pallete, add new block.

5. Configure the block properties as shown below.

Name

Firebase to Map

Type

if block (c)

Type name

Firebase to Map

Color

#9C27B0

Spec

FirebaseDb %s.inputOnly getDataTo %m.varMap

Code


%1$s.addValueEventListener(new ValueEventListener() {
	@Override
	public void onDataChange(DataSnapshot _dataSnapshot) {

				%2$s = _dataSnapshot.getValue(new GenericTypeIndicator<HashMap<String, Object>>(){});
				%3$s
	}
	@Override
	public void onCancelled(DatabaseError _databaseError) {
	}
});


6. Save it.

7. Refresh and use the block.



Comments

Popular posts from this blog

Simple car racing android game in Sketchware

How to enable upload from webview in Sketchware?

Simple Audio recorder app in Sketchware

Custom dialog box in Sketchware using CustomView

How to enable download in webview in Sketchware apps?