Permalink
Browse files

added simple content provider for later reuse.

  • Loading branch information...
inazaruk committed Jul 7, 2011
1 parent 96715ac commit c96fd97298610499b9007c77c42b283512e88af8
Showing with 727 additions and 0 deletions.
  1. +8 −0 ContentProvider/ContentConsumer/.classpath
  2. +40 −0 ContentProvider/ContentConsumer/.project
  3. +20 −0 ContentProvider/ContentConsumer/AndroidManifest.xml
  4. +13 −0 ContentProvider/ContentConsumer/default.properties
  5. +36 −0 ContentProvider/ContentConsumer/proguard.cfg
  6. BIN ContentProvider/ContentConsumer/res/drawable-hdpi/icon.png
  7. BIN ContentProvider/ContentConsumer/res/drawable-ldpi/icon.png
  8. BIN ContentProvider/ContentConsumer/res/drawable-mdpi/icon.png
  9. +12 −0 ContentProvider/ContentConsumer/res/layout/main.xml
  10. +5 −0 ContentProvider/ContentConsumer/res/values/strings.xml
  11. +68 −0 ContentProvider/ContentConsumer/src/com/inazaruk/contentconsumer/ContentConsumerActivity.java
  12. +8 −0 ContentProvider/ContentProvider/.classpath
  13. +40 −0 ContentProvider/ContentProvider/.project
  14. +19 −0 ContentProvider/ContentProvider/AndroidManifest.xml
  15. +12 −0 ContentProvider/ContentProvider/default.properties
  16. +36 −0 ContentProvider/ContentProvider/proguard.cfg
  17. BIN ContentProvider/ContentProvider/res/drawable-hdpi/icon.png
  18. BIN ContentProvider/ContentProvider/res/drawable-ldpi/icon.png
  19. BIN ContentProvider/ContentProvider/res/drawable-mdpi/icon.png
  20. +12 −0 ContentProvider/ContentProvider/res/layout/main.xml
  21. +5 −0 ContentProvider/ContentProvider/res/values/strings.xml
  22. +15 −0 ContentProvider/ContentProvider/src/com/inazaruk/contentprovider/MainActivity.java
  23. +222 −0 ContentProvider/ContentProvider/src/com/inazaruk/contentprovider/PreferenceSpyProvider.java
  24. +7 −0 ContentProvider/ContentProviderLib/.classpath
  25. +33 −0 ContentProvider/ContentProviderLib/.project
  26. +12 −0 ContentProvider/ContentProviderLib/AndroidManifest.xml
  27. +12 −0 ContentProvider/ContentProviderLib/default.properties
  28. +36 −0 ContentProvider/ContentProviderLib/proguard.cfg
  29. BIN ContentProvider/ContentProviderLib/res/drawable-hdpi/icon.png
  30. BIN ContentProvider/ContentProviderLib/res/drawable-ldpi/icon.png
  31. BIN ContentProvider/ContentProviderLib/res/drawable-mdpi/icon.png
  32. +12 −0 ContentProvider/ContentProviderLib/res/layout/main.xml
  33. +5 −0 ContentProvider/ContentProviderLib/res/values/strings.xml
  34. +39 −0 ContentProvider/ContentProviderLib/src/com/inazaruk/preferencespy/provider/PreferenceSpy.java
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="src" path="ContentProviderLib_src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ContentConsumer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>ContentProviderLib_src</name>
+ <type>2</type>
+ <locationURI>_android_ContentProviderLib_3b56cbb/src</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.inazaruk.contentconsumer"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="8" />
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
+ <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".ContentConsumerActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
@@ -0,0 +1,13 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
+android.library=false
+android.library.reference.1=../ContentProviderLib
@@ -0,0 +1,36 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, ContentConsumerActivity!</string>
+ <string name="app_name">ContentConsumer</string>
+</resources>
@@ -0,0 +1,68 @@
+package com.inazaruk.contentconsumer;
+
+import java.util.Date;
+
+import android.app.Activity;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.inazaruk.preferencespy.provider.PreferenceSpy.Preferences;
+
+public class ContentConsumerActivity extends Activity
+{
+ private static final String TAG = ContentConsumerActivity.class.getSimpleName();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ /* insert */
+ ContentValues values = new ContentValues();
+ values.put(Preferences.REMOTE_PACKAGE, getPackageName());
+ values.put(Preferences.REMOTE_PREF_NAME, "remotePreferences");
+ values.put(Preferences.LOCAL_PREF_NAME, "localPreferences");
+ values.put(Preferences.REMOTE_LAST_MODIFIED_TIME, 0L);
+ Uri uri = getContentResolver().insert(Preferences.CONTENT_URI, values);
+
+ printValues();
+
+ /* update */
+ values = new ContentValues();
+ values.put(Preferences.REMOTE_LAST_MODIFIED_TIME, new Date().getTime());
+ getContentResolver().update(uri, values, null, null);
+ }
+
+ public void printValues()
+ {
+ String [] projection = new String[]
+ {
+ Preferences._ID,
+ Preferences.REMOTE_PACKAGE,
+ Preferences.REMOTE_PREF_NAME,
+ Preferences.LOCAL_PREF_NAME,
+ Preferences.REMOTE_LAST_MODIFIED_TIME
+ };
+
+ Cursor cursor = this.managedQuery(Preferences.CONTENT_URI,
+ projection, null, null, null);
+
+ cursor.moveToFirst();
+ do
+ {
+ String id = cursor.getString(cursor.getColumnIndex(Preferences._ID));
+ String pkg = cursor.getString(cursor.getColumnIndex(Preferences.REMOTE_PACKAGE));
+ String remoteName = cursor.getString(cursor.getColumnIndex(Preferences.REMOTE_PREF_NAME));
+ String localName = cursor.getString(cursor.getColumnIndex(Preferences.LOCAL_PREF_NAME));
+ long lastModified = cursor.getLong(cursor.getColumnIndex(Preferences.REMOTE_LAST_MODIFIED_TIME));
+
+ Log.v(TAG, "Record: "+id+", "+pkg+", "+remoteName+", "+localName+", "+lastModified);
+ }
+ while(cursor.moveToNext());
+ cursor.close();
+ }
+}
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="src" path="ContentProviderLib_src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ContentProvider</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>ContentProviderLib_src</name>
+ <type>2</type>
+ <locationURI>_android_ContentProviderLib_3b56cbb/src</locationURI>
+ </link>
+ </linkedResources>
+</projectDescription>
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.inazaruk.contentprovider"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="8" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <provider android:name=".PreferenceSpyProvider" android:authorities="com.inazaruk.preferencespy.provider"/>
+ </application>
+</manifest>
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
+android.library.reference.1=../ContentProviderLib
@@ -0,0 +1,36 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, MainActivity!</string>
+ <string name="app_name">ContentProvider</string>
+</resources>
@@ -0,0 +1,15 @@
+package com.inazaruk.contentprovider;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class MainActivity extends Activity
+{
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ }
+}
Oops, something went wrong.

0 comments on commit c96fd97

Please sign in to comment.