Finding database path is impossible

后端 未结 2 709
有刺的猬
有刺的猬 2021-01-27 20:43

I am quite new to android development and right now I\'m trying to create a database through a class extending SQLiteOpenHelper. I am positively sure that the data is being sto

2条回答
  •  庸人自扰
    2021-01-27 21:15

    How about setting the dbname as full path:

    String DATABASE_NAME = "/data/data/"+packageName+"db.db";
    

    or put your db in SD card:

    String DATABASE_NAME= Environment.getExternalStorageDirectory()+packageName+"db.db";
    

    pass the dbPath in your code:

    public DatabaseImplementation(Context context) 
    {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
    

提交回复
热议问题