package com.darwinsys.contentstacker;

import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Browser;
import android.util.Log;

public class DemoActivity extends Activity {
	
	private static final String TAG = DemoActivity.class.getSimpleName();
	
	String[] from = {
            Browser.BookmarkColumns.TITLE,
            Browser.BookmarkColumns.URL,
    };


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ContentResolver cr = getContentResolver();
		
		// First set up the StackingContentProvider's configuration: 
		// "insert" the Bookmarks Authority into the Stacker
		ContentValues values = new ContentValues();
		values.put(StackingContentProvider.CONTENT_PROVIDER_AUTHORITY_KEY, 
				Browser.BOOKMARKS_URI.toString());
		final Uri inserted1 = cr.insert(StackingContentProvider.CONTENT_URI, values);
		Log.d(TAG, "First insert is " + inserted1);
		
		// Do it again so we can double up insertions (this is just
		// a contrived demo after all).
		final Uri inserted2 = cr.insert(StackingContentProvider.CONTENT_URI, values);
		Log.d(TAG, "Second insert is " + inserted2);
		
		// Now we do an actual insert
		values.clear();
		values.put(Browser.BookmarkColumns.TITLE, "Test URL 1");
		values.put(Browser.BookmarkColumns.URL, "http://darwinsys.com/");
		final Uri insertedBookmark = cr.insert(StackingContentProvider.CONTENT_URI, values);
		Log.d(TAG, "Bookmark URL is " + insertedBookmark);
		
	}
}

@@ -139,16 +139,48 @@
 Values;%0A
+import android.database.Cursor;%0A
 import a
@@ -414,12 +414,15 @@
 g%5B%5D 
-from
+columns
  = %7B
@@ -1615,13 +1615,255 @@
 rk);%0A%09%09%0A
+%09%09// Now we list the Bookmarks and see what's there%0A%09%09Cursor cur = cr.query(Browser.BOOKMARKS_URI, columns, null, null, null);%0A%09%09while (cur.moveToNext()) %7B%0A%09%09%09Log.d(TAG, %22Read bookmark: %22 + cur.getString(0) + %22-%3E%22 + cur.getString(1));%0A%09%09%7D%0A%09%09%0A
 %09%7D%0A%7D%0A

Add another diagnostic (temporary; should put into ListView!)