I am making an app for my IT Department in my University. And i want to use a database (sqlite) which i have already created with SQLite Browser. Unfortunally i cant seem to find any good tutorial to help me although i have searched everywhere. What i want to do is just simple open my database file and access it to get data based on what i want every time. Is there any way to achieve something like it and if yes can someone please show me an efficient way cause i am new to Android programming. And a fact is that you always need someone to teach you stuff like it! Thanks a lot in advance!
-
Complete example is here: http://stackoverflow.com/questions/9109438/using-already-created-database-with-android/9109728#9109728 – Yaqub Ahmad Jun 28 '12 at 05:25
-
I know this is closed and an old posting but I would like to add this info if that's ok. I use Basic4Android also known as B4A. It's a lot easier to use than straight Java and will allow Pavlos to use SQLite in data entry forms created with B4A as well as manipulate the data as needed. – Emad-ud-deen Jun 28 '17 at 14:50
2 Answers
If you want to create a pre-loaded DB outside of your app and use it in your app later, you will have to put it in your assets
directory and then copy it to your apps databases
directory the first time your app is started.
This is due to the fact that as a security measure, on real (unrooted) devices nothing but your own app is allowed access to their data directory (which contains the databases directory).
There is a good tutorial for creating/copying your own DB outside of the app and copying it to the apps databases directory here.

- 16,318
- 9
- 52
- 84
-
Neither of those tutorials helped even a bit! I cant find a way to use them! – Pavlos Jun 28 '12 at 07:10
You can manage a database on android by setting up a class extending SQLiteOpenHelper
, that will manage the database (define the tables, the columns of each tables, create the db...),
and use another class that will interact with the database and your datas.
You can see that tutorial that will explain that better than I do : http://www.vogella.com/articles/AndroidSQLite/article.html#overview
Have fun :)

- 3,819
- 2
- 37
- 53