I produced a static approach to access my database on a single of my activities however i keep getting error on opening the database.

MainActivity

 public static String getStudentData() {

    SQLiteDatabase sampleDB =  null;

    try {
            //NOT WORKING
        sampleDB =  SQLiteDatabase.openDatabase("studentDB",null, SQLiteDatabase.CREATE_IF_NECESSARY); 
            //Also not working
        //sampleDB =  SQLiteDatabase.openOrCreateDatabase("studentDB", null);

        Cursor c = sampleDB.rawQuery("SELECT * FROM student where id='1'", null);

        if (c != null ) {
            if  (c.moveToFirst()) {
                do {
                    //...                       
                }while (c.moveToNext());
            } 
        }
        c.close();
    } catch (Exception se ) {
    } finally {
            sampleDB.close();
    }
}

OtherActivity

String student = MainActivity.getStudentData();

I've been getting sqlite3_open_v2("studentDB", &handle, 6, NULL) failed. Cant find wrong... I've also attempted using MODE_WORLD_WRITEABLE. Presently using MODE_PRIVATEfor database creation. Please assist me!

First argument to openDatabase ought to be full road to db therefore if:

//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";

private static String DB_NAME = "studentDB";

then you definitely should call:

sampleDB =  SQLiteDatabase.openDatabase(DB_PATH + DB_NAME,null, SQLiteDatabase.CREATE_IF_NECESSARY);