Posts

Showing posts from September, 2024

A simple sqlite example in Sketchware

Image
 In this example, the user can save details of pupils (name, age and place) in sqlite database in android app, and view the data in a ListView. Create a new project in Sketchware. In Options/Configuration, click on Java/Kotlin manager. Create a new Java class file with name DbHandler. Put following codes as contents of this DbHandler.java file. package com.my.newproject2; import android.content.ContentValues; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.Cursor; public class DbHandler extends SQLiteOpenHelper { private static final String DB_NAME = "studentdb"; private static final int DB_VERSION = 1; private static final String TABLE_NAME = "students"; private static final String ID_COL = "id"; private static final String NAME_COL = "name"; private static final String AGE_COL = "age"; private s...

An app for encrypting text in Sketchware

Image
Create a new app with four pages or Activity: MainActivity, NewnoteActivity, OldnoteActivity, ViewnoteActivity . In main.xml add two buttons. On button_new click, move to NewnoteActivity. On button_old click, move to OldnoteActivity. In newnote.xml View, add an Edittext (edittext1) and a Button (fab1) . In NewnoteActivity , add a Shared preferences component (sp:sp) . Add a more block called newitems and put following code in it: } byte[] cipherText; byte[] secretKeyen; byte[] IV = new byte[16]; { Add another more block called encrypt and put following code in it: } public static byte[] encrypt(byte[] plaintext, javax.crypto.SecretKey key, byte[] IV) throws Exception{ javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("AES"); javax.crypto.spec.SecretKeySpec keySpec = new javax.crypto.spec.SecretKeySpec(key.getEncoded(), "AES"); javax.crypto.spec.IvParameterSpec ivSpec = new javax.crypto.spec.IvParameterSpec(IV); cipher.init(javax.crypto...