Reputation: 155
I'm new to Android development and I've just started learning the basics of user-interface development. In my app, I have a spinner and I want to populate the spinner with values from the database. So, for taking values from the database, there have to be some values in it. How do I insert values to the database without writing a program? Can I insert it in any other way like how we insert values in MySQL and Oracle databases? Hope that my problem is well understood.
Upvotes: 9
Views: 9485
Reputation: 227
If you want to inset the data manually(fully graphical) do the following:
Upvotes: 2
Reputation: 48592
Can I insert it in any other way like how we insert values in MySQL and Oracle databases? Hope that my problem is well understood.
Yes you can insert the data in SQLite database manually by following steps.
Steps to follow:
1) Go to your sdk-tool directory . (Example - E:\android-sdk-windows\tools>)
2) Type adb shell and press enter
3) cd data
4) cd data
5) cd your package name
6) cd databases
Once you reach here then do these steps to create database and create tables then insert data into it.
sqlite3 your_database_name.db;
SQLite version 3.7.7 2011-06-25 16:35:41
Enter ".help" for instructions Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE province_table (pid INTEGER PRIMARY KEY AUTOINCREMENT, pname TEXT);
sqlite> INSERT INTO province_table (pname) values ('Quebec');
sqlite> ...
sqlite> .q
.q for quiet from SQLlite and now you have database your_database_name.db
.
But here in your case if you want to create the database for all mobile such like that once your application run the start database manipulation then you must to do it programmatically.
Upvotes: 0
Reputation: 11185
You can use the sqllite3 tool from an adb shell to perform queries manually. I would not rely on it being present on production devices though (without rooting and going through a few painful steps). You can use the tool on the emulator.
adb -s emulator-5554 shell
# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version 3.3.12
Upvotes: 0