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
Post a Comment