where is my android database? -
i created android application on eclipse made database(just testing) , have use database in final application , store information app. importantly have able share database others. , cant find file shared. dont have knowledge of sql thought stored in .db format tried search couldnt find file. can see entries not file.
i ran app on phone , still not find database file, instead found database files of other apps whatsapp.
so, database ?
whether using emulator or real device, can use ddms(window-> open perspective-> ddms) navigate db.
in ddms, there file explorer( if not visible, window-> show view-> file explorer ).
now there, can navigate db /data/data/<app-package-name>/databases/<database-name>
now, save file, click on save button @ top right corner of file explorer.
update:
actually, before table row insertion, can't see data base. if want static table predefined data, can insertion @ time of table creation. eg:- refer oncreate() method->
public class dbhelper extends sqliteopenhelper { sqlitedatabase db; public dbhelper(context context) { super(context, "pics.db", null, 1); } @override public void oncreate(sqlitedatabase db) { db.execsql("create table picture(_id integer primary key,pics varchar(20))"); db.execsql("insert picture values(1001,'one.jpg')"); db.execsql("insert picture values(1002,'two.jpg')"); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub } public long insert(contentvalues cv) { db = getwritabledatabase(); long l=db.insert("picture", null, cv); db.close(); return l; } public cursor getallvalues() { db=getreadabledatabase(); cursor cr=db.query("picture", null, null, null, null, null, "_id"); db.close(); return cr; } }
Comments
Post a Comment