Android: Remove hard coding of database path -


in application in sqlite data base helper class code of constructor follows:

public databasehelper(context context) {         super(context, database_name, null ,database_version);     this.mycontext = context;     //the android's default system path of application database.     db_path =  "/data/data/mypackage/databases/"; } 

where getting warning as:

do not hardcode "/data/"; use context.getfilesdir().getpath() instead

so tried:

db_path = "/data/data/" + context.getpackagename() + "/databases/";  

but getting same warning. should now.

you can 1 thing. not hard core it. try as:

db_path =  mycontext.getdatabasepath(database_name).getpath(); 

this remove warnings.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -