Last steps with my provider.
authorgumartinm <gu.martinm@gmail.com>
Fri, 17 Feb 2012 07:07:54 +0000 (08:07 +0100)
committergumartinm <gu.martinm@gmail.com>
Fri, 17 Feb 2012 07:07:54 +0000 (08:07 +0100)
It works smoothly.

Android/Testing/Test3/src/de/android/test3/IndexerProvider.java
Android/Testing/Test3/src/de/android/test3/MobieAdHttpClient.java

index f3abcc9..1dec16c 100644 (file)
@@ -33,6 +33,8 @@ public class IndexerProvider extends ContentProvider {
     // The incoming URI matches the Note ID URI pattern
     private static final int INDEXER_ID = 2;
     
+    private static final int INDEXER_IDAD = 3;
+    
     static {
        
        /*
@@ -48,6 +50,8 @@ public class IndexerProvider extends ContentProvider {
         // to a index ID operation
         sUriMatcher.addURI("de.android.test3.provider", Indexer.Index.TABLE_NAME + "/#", INDEXER_ID);
         
+        sUriMatcher.addURI("de.android.test3.provider", Indexer.Index.TABLE_NAME + "/" + Indexer.Index.COLUMN_NAME_ID_AD + "/#", INDEXER_IDAD);
+        
         
         /*
          * Creates and initializes a projection map that returns all columns
@@ -275,7 +279,15 @@ public class IndexerProvider extends ContentProvider {
                           // the position of the note ID itself in the incoming URI
                           uri.getPathSegments().get(1));
                    break;
-
+                   
+               case INDEXER_IDAD:
+                       qb.setProjectionMap(sIndexerProjectionMap);
+                       qb.appendWhere(
+                       Indexer.Index.COLUMN_NAME_ID_AD + // the name of the ID column
+                          "=" +
+                          // the position of the Advertisement ID itself in the incoming URI
+                          uri.getPathSegments().get(2));
+                       break;
                default:
                    // If the URI doesn't match any of the known patterns, throw an exception.
                    throw new IllegalArgumentException("Unknown URI " + uri);
index 2f349ee..ad024d7 100644 (file)
@@ -98,9 +98,12 @@ public class MobieAdHttpClient implements Runnable
                                           ContentValues values = new ContentValues();
                                           values.put(Indexer.Index.COLUMN_NAME_PATH, "18188181");
                                           values.put(Indexer.Index.COLUMN_NAME_ID_AD, "22");
-                                          Uri probando = Uri.parse("content://" + "de.android.test3.provider" + "/" + "indexer");
-                                          this.context.getContentResolver().insert(probando, values);
+                                          Uri probando = Uri.parse("content://" + "de.android.test3.provider" + "/" + "indexer" + "/idad/" + "22");
+                                          
                                           Cursor cursor = this.context.getContentResolver().query(probando, null, null, null, null);
+                                          if (cursor != null) {
+                                          }
+                                          //this.context.getContentResolver().insert(probando, values);
                                           downloadAds((Integer) objects.get("id"), (String)objects.get("domain"), (String)objects.get("link"));   
                                   }    
                           } catch (URISyntaxException e) {