i think it is work for you
**I am copy database in SdCard then access ** .
it is my database helper class
public class OpenDatabaseHelper extends SQLiteOpenHelper {
static final String DATABASE_NAME = "MyDB";
.
.
.
public OpenDatabaseHelper(Context context) {
// super(context, name, factory, version);
super(context, Environment.getExternalStorageDirectory()
+ File.separator + "/DataBase/" + File.separator
+ DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
.
.
.
}
create object in Activity class
OpenDatabaseHelper db = new OpenDatabaseHelper(YourActivity.this);
call any method of database
db.DataBasemethod();
then put this code
try {
String destPath = Environment.getExternalStorageDirectory().toString();
File f = new File(destPath);
if (!f.exists()) {
f.mkdirs();
f.createNewFile();
// ---copy the db from the /data/data/ folder into
// the sdcard databases folder--- here MyDB is database name
CopyDB(new FileInputStream("/data/data/" + getPackageName()+ "/databases"), new FileOutputStream(destPath+ "/MyDB"));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
public void CopyDB(InputStream inputStream, OutputStream outputStream)
throws IOException {
// ---copy 1K bytes at a time---
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
}
inputStream.close();
outputStream.close();
}