You will need to keep an array with all the stars collected in local storage or on an sql server. On start of main many layout load the array from the local storage. Lets say cell 0 keeps level 1 stars, cell 1 keeps level 2 stars etc. Then you check each cell value and if cell is equal to 3 then unlock the level. Locking unlocking can be done using different object one clickable the other not, so when level is unlock you make the none clickable object to spawn the clickable one to its position and destroy the none clickable one.
Its pretty hard to get it right on a first try, took me 2-3 days to get it right on my game. Here is a screenshot from my game that might help you.
Edit: here is the link of the game in the arcade, if you are curious how the menu looks like.
https://www.scirra.com/arcade/puzzle-ga ... sion-18913