Get database path

后端 未结 4 838
我在风中等你
我在风中等你 2020-12-10 00:57

Im new to android and I want to create kind of CRUD with SQLite.

I have a public class DataBaseHelper which have a constructor:

public D         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 01:39

    You can use getDatabasePath method inside your helper's constructor:

    public class MyDatabase extends SQLiteAssetHelper {
    
        private static final String DATABASE_NAME = "wl.db";
        private static final int DATABASE_VERSION = 1;  
        public String databasePath = "";    
    
        public MyDatabase(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
    
            databasePath = context.getDatabasePath("wl.db").getPath();
        }
    

提交回复
热议问题