Warning : Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead Warning : Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead sqlite sqlite

Warning : Do not hardcode "/data/"; use Context.getFilesDir().getPath() instead


The tip that eclipse gives you is not good enough.

You can get database path with context.getDatabasePath();You should pass the desired name to the file (no matter if it exists or not), in your case exampledb.sqlite

So your code will be:

File outFile =myContext.getDatabasePath(DATABASE_NAME);String outFileName =outFile.getPath() ;

of course, myContext has to be the current context. This is for instance the running activity or service that is calling this.


Do as follows :

public DataBaseHelperClass(Context context) {           super(context, DATABASE_NAME, null ,DATABASE_VERSION);    this.myContext = context;    //The Android's default system path of your application database.    DB_PATH = myContext.getDatabasePath(DATABASE_NAME).getPath();}

You will not get error or warning.


Just use the context of the activity/app for getting the path like:

Context c = getApplicationContext();c.getFilesDir().getPath();