//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);
}
Asked
Active
Viewed 271 times
-1

Sanket Kachhela
- 10,861
- 8
- 50
- 75

Chella Kumaran
- 149
- 2
- 10
1 Answers
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

Sanket Kachhela
- 10,861
- 8
- 50
- 75
-
getting error in this line this.myContext = context; – Chella Kumaran Sep 18 '13 at 08:07
-
have you declare myContext as global variable.? – Sanket Kachhela Sep 18 '13 at 09:24
-
ya got it worked...Thanks..@Sanket Kachhela...and also have a doubt that it is possible to transfer sqlite db data to sql server 2008..? – Chella Kumaran Sep 18 '13 at 09:46
-
yes you can do through via webservices or uploading csv file on to server and server code add that csv file data into his sql server 2008 database – Sanket Kachhela Sep 18 '13 at 09:52
-
is there any tutorial or blog available to view this example..im really very new to these process...thanks in advance – Chella Kumaran Sep 18 '13 at 09:56
-
follow this SO question http://stackoverflow.com/a/4126746/942224 – Sanket Kachhela Sep 18 '13 at 09:58
-
this is using webservice ???? i need without webservice frnd...! – Chella Kumaran Sep 18 '13 at 10:18