Public static final String quantity = "quantity" Public static final String desc = "desc" Public static final String pname = "pname" Public static final String order_id = "_id" Public static final String product_table = "tblproduct" Public static final String DB_NAME = "mydb.db" Public class DbHelper extends SQLiteOpenHelper if your database is big you can display progress bar for loading process. so for the first time it will create or copy your database. From your Main Activity only first time call Oncreate method of SQLiteOpenHelper Class. beacuse it call onCreate method internally. this code will check if database exist then do nothing because if you won't check it will overwrite your database every time you call getWritableDatabase Or getReadableDatabase Method. if you have done some other task in oncreate method then rearrange it after this code. ![]() you have to put this code in onCreate method. Put below code in your SQLiteOpenHelper Class file. Just go through the full tutorial and i hope it will solve all problems regarding coping database. ![]() so to save your time and without doing all this you can copy database from assets folder to internal storage. You have to debug your app and in android studio it is also tedious task. some times it also happens you can not copy big database and it is also big problem in android. For that you have to dig up in to your code. even if there is table and also data in it. For some of them you can find online solution but some are really unknown like null pointer exception or getWritableDatabase method called recursively etc. And i came across many problems, Some of them were really annoying and confusing. ![]() Yesterday i spent whole day behind using my database i mean database is created i just require to use it in app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |