MainActivity.java
PresidentContract.java
PresidentProvider.java
Helper.java
activity_main.xml
strings.xml
AndroidManifest.xml
.
The
<manifest>
element contains two
<permission>
elements.
The
<application>
element contains a
<provider>
element.
build.gradle
(Module: app)
MainActivity.java
PresidentContract.java
:
identical to the
PresidentContract.java
in the content provider,
except for the
package
statement.
activity_main.xml
strings.xml
AndroidManifest.xml
build.gradle
(Module: app)
To create class
PresidentProvider
,
select the
app/java/president
folder in the Android Studio
project
view
and pull down
File → New → Other → Content Provider
First run the content provider
President
,
and leave it running.
You can ignore its
Activity
.
Then run
PresidentCleint
as many times as you want.
After its first run,
the content provider’s database looks like this:
adb devices List of devices attached 192.168.57.101:5555 device adb -s 192.168.57.101:5555 shell cd /data/data/edu.nyu.scps.president/databases pwd /data/data/edu.nyu.scps.president/databases ls -l -rw-rw---- u0_a109 u0_a109 20480 2015-08-08 07:18 presidents.db sqlite3 presidents.db .tables android_metadata presidents .dump android_metadata PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE android_metadata (locale TEXT); INSERT INTO "android_metadata" VALUES('en_US'); COMMIT; .dump presidents PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE presidents ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT ); INSERT INTO presidents VALUES(1,'Washington'); INSERT INTO presidents VALUES(2,'John Adams'); COMMIT; .quit exit
adb -s 192.168.57.101:5555 shell sqlite3 /data/data/edu.nyu.scps.president/databases/presidents.db "'.dump presidents'" PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE presidents ( _id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT ); INSERT INTO presidents VALUES(1,'Washington'); INSERT INTO presidents VALUES(2,'John Adams'); COMMIT;