//this is my handler class
public class DBHandler extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "feedbackDB.db";
private static final String TABLE_FEEDBACK = "feedback";
public DBHandler(Context context) {
super(context,context.getExternalFilesDir(null).getAbsolutePath()+DATABASE_NAME, null, DATABASE_VERSION);
}
public void openDataBase(SQLiteDatabase db) throws SQLException {
//Open the database
String myPath = context.getExternalFilesDir(null).getAbsolutePath() + DATABASE_NAME;
db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}
質問する
259 次
1 に答える
1
Declare DB_PATH value in constructor and use it whenever you want so you dont need to assign every time
public DBHandler(Context context)
{
super(context, DB_NAME, null, 1);
this.myContext = context;
DB_PATH = Environment.getExternalStorageDirectory()
+ File.separator + "/.folder name/" + File.separator;
File f = new File(DB_PATH);
f.mkdirs();
}
and use it as DB_PATH+DATABASE_NAME
to perform database operation
于 2013-09-18T07:37:01.530 に答える