I have a dump database. I just wanted to insert the database into my application and retrive it. Please help me. I am new to android .. Thanks in advance.
3
-
Where your database is and where you want to copy ?GrIsHu– GrIsHu2013-09-24 05:59:27 +00:00Commented Sep 24, 2013 at 5:59
-
Please ask only full question with your code..Manish Srivastava– Manish Srivastava2013-09-24 06:01:01 +00:00Commented Sep 24, 2013 at 6:01
-
I am doing a vocabulary application. It contains nearly 8000 records. So how can i insert into the android application and retrive it.. Is there any code or procedure for that ? Kindly helpSibhiRajan– SibhiRajan2013-09-24 06:03:08 +00:00Commented Sep 24, 2013 at 6:03
Add a comment
|
3 Answers
void checkDB() throws Exception {
try {
SQLiteDatabase dbe = SQLiteDatabase
.openDatabase(
"/data/data/yourpackagename/databases/yourfilename.sqlite",
null, 0);
Log.d("opendb", "EXIST");
dbe.close();
} catch (Exception e) {
AssetManager am = getApplicationContext().getAssets();
OutputStream os = new FileOutputStream(
"/data/data/yourpackagename/databases/yourfilename.sqlite");
byte[] b = new byte[100];
int r;
InputStream is = am.open("yourfilename.sqlite");
while ((r = is.read(b)) != -1) {
os.write(b, 0, r);
}
Log.i("DATABASE_HELPER", "Copying the database ");
is.close();
os.close();
}
}
Please Refer this link
1 Comment
Vignesh Bala
OMG! I already tried with that link u provided but didn't changed the database Field id to "_id". Thanks a lot
There's a library for that, I used it once, too.