Running a method in a class which does not extend an activity on android
<p>I am currently developing an application on android. </p>

<p>I would like a class which creates the database and tables in a separated from the Activity screen. </p>

<pre><code>public void createDatabase()
    {
        try
        {
            SQLiteDatabase myDB;
            myDB = this.openOrCreateDatabase("PasswordManager", Context.MODE_PRIVATE, null);

            myDB.execSQL("CREATE TABLE IF NOT EXISTS `users` (`use_userID` int(11) NOT NULL, `use_username` varchar(25) DEFAULT NULL," +
                    "`use_usePassword` char(1) DEFAULT NULL, `use_password` varchar(150) DEFAULT NULL, PRIMARY KEY (`use_userID`))");

            myDB.execSQL("CREATE TABLE IF NOT EXISTS `password` (`pas_loginID` int(11) NOT NULL, `pas_userID` int(11) DEFAULT NULL," +
                    "`pas_company` varchar(50) NOT NULL, `pas_companyURL` varchar(250) DEFAULT NULL, `pas_username` " +
                    "varchar(150) NOT NULL, `pas_password` varchar(150) NOT NULL, `pas_type` varchar(50) NOT NULL, " +
                    "PRIMARY KEY (`pas_loginID`))");
        }
        catch (SQLiteException sqlEx)
        {
            Log.d("Database Error", sqlEx.toString());
        }
        catch (Exception ex)
        {
            Log.d("General Error", ex.toString());
        }
    }
</code></pre>

<p>The class isn't activity i.e. it is not showing a screen, it is just going to do certain methods which will need to happen regularly so I haven't got to repeat code. How can I do this. It keeps on coming up with a Null Pointer Exception</p>
