0

I create Database in DB Browser For SQlite. simple database - with one table called Students with two row:

1.id - integer
2.name -text

I want to use this database in android studio app.For example I need an app,which will print the names of students from database Students; I've two questions:

  1. Where Should I put the Students.db file?
  2. How to use/read the database in my app.

I'm searching for it for a while but cant find solution. Can you give me a good tutorial or just answer the question. Thanks

Lazare Giunashvili
  • 197
  • 1
  • 2
  • 13

2 Answers2

0

There is a well defined pattern of making a "DataBaseAdapter" class in Android.

http://android-er.blogspot.com/2011/06/simple-example-using-androids-sqlite.html

Has an example.

you create a class SQLiteHelper that extends SQLiteOpenHelper. Then you follow the general pattern that the SQLiteAdapter class follows. This approach handles creating the sqlite db for you within your app-private internal storage.


To read from the DB, you make an instance of your SQLiteAdapter class, and then call insert(...), delete(...), query(...), etc. to actually manipulate your db.

mawalker
  • 2,072
  • 2
  • 22
  • 34
0

Basically you would like to use an existing sqlite database, I think this question rely on a same idea, that answer could help you too. Or if you don't have to use an exiting database file, your starting point can be this tutorial.

Community
  • 1
  • 1
Gex
  • 2,092
  • 19
  • 26