androiddatabasesqliteinstalled-applications

SQLite Database - Create new tables and set Table name through a popup


I am creating an app blocking Application and would like to know a few things:

  1. How to load a list of installed apps into a database table.
  2. Create a new table within the database and set the table name through an EditText field or an AlertDialog.
  3. Call in selected apps into another activity
  4. List of apps needs to have a CheckBox next to them to select which apps to carry over to another

Completed Events


I hope I've provided enough details or if this makes any sense at all. Thank you in advance and I hope someone will be able to help me with this problem. If needed I can post segments of my already existing code to make things easier?


Solution

  • For using a Android Database, I recommend to follow this tutorial:

    Android | Simple SQLite Database Tutorial

    After this tutorial you will understand how the android database works, how you can create tables:

    @Override
    public void onCreate(SQLiteDatabase db) {
        // SQL statement to create book table
        String CREATE_BOOK_TABLE = "CREATE TABLE books ( " +
                    "id INTEGER PRIMARY KEY AUTOINCREMENT, " + 
                    "title TEXT, "+
                    "author TEXT )";
    
        // create books table
        db.execSQL(CREATE_BOOK_TABLE);
    }
    

    And how to

    1. addItemsToDatabase(Object object)
    2. getItemsFromDatabase(int id)
    3. getAllItemsFromDatabase()
    4. updateItemInDatabase(Object object)
    5. deleteItemFromDatabase(Object object)

    When you know all this you can create own methods to use!