Latest changes in Android mobiads application.
authorgumartinm <gustavo@gumartinm.name>
Sun, 10 Jun 2012 22:27:06 +0000 (00:27 +0200)
committergumartinm <gustavo@gumartinm.name>
Sun, 10 Jun 2012 22:27:06 +0000 (00:27 +0200)
No time for comments.  :(

14 files changed:
Android/MobiAds/gen/de/android/mobiads/R.java
Android/MobiAds/res/layout/ads_entry_list_item.xml [new file with mode: 0644]
Android/MobiAds/res/layout/news_entry_list_item.xml [deleted file]
Android/MobiAds/res/menu/menuads.xml
Android/MobiAds/res/values/strings.xml
Android/MobiAds/src/de/android/mobiads/MobiAdsMainActivity.java
Android/MobiAds/src/de/android/mobiads/batch/MobiAdsBatch.java
Android/MobiAds/src/de/android/mobiads/list/AdsEntry.java
Android/MobiAds/src/de/android/mobiads/list/AdsEntryAdapter.java
Android/MobiAds/src/de/android/mobiads/list/MobiAdsListActivity.java
Android/MobiAds/src/de/android/mobiads/list/MobiAdsNewAdsActivity.java
Android/MobiAds/src/de/android/mobiads/provider/Indexer.java
Android/MobiAds/src/de/android/mobiads/provider/IndexerOpenHelper.java
Android/MobiAds/src/de/android/mobiads/provider/IndexerProvider.java

index a0ac68e..2928863 100644 (file)
@@ -16,30 +16,34 @@ public final class R {
         public static final int wheelnotification=0x7f020002;
     }
     public static final class id {
-        public static final int ads_entry_icon=0x7f05000e;
-        public static final int ads_entry_text=0x7f050010;
-        public static final int ads_entry_title=0x7f05000f;
-        public static final int button_bind=0x7f050007;
-        public static final int button_lislocalads=0x7f05000d;
-        public static final int button_startservice=0x7f05000b;
-        public static final int button_stopservice=0x7f050009;
-        public static final int button_unbind=0x7f050008;
-        public static final int frameLayout1=0x7f050000;
-        public static final int frameLayout2=0x7f050003;
-        public static final int frameLayout3=0x7f050005;
-        public static final int frameLayout4=0x7f05000a;
-        public static final int frameLayout5=0x7f05000c;
-        public static final int list=0x7f050006;
-        public static final int login_button=0x7f050004;
-        public static final int password=0x7f050002;
-        public static final int username=0x7f050001;
+        public static final int ads_entry_icon=0x7f060000;
+        public static final int ads_entry_text=0x7f060002;
+        public static final int ads_entry_title=0x7f060001;
+        public static final int button_bind=0x7f06000a;
+        public static final int button_lislocalads=0x7f060010;
+        public static final int button_startservice=0x7f06000e;
+        public static final int button_stopservice=0x7f06000c;
+        public static final int button_unbind=0x7f06000b;
+        public static final int frameLayout1=0x7f060003;
+        public static final int frameLayout2=0x7f060006;
+        public static final int frameLayout3=0x7f060008;
+        public static final int frameLayout4=0x7f06000d;
+        public static final int frameLayout5=0x7f06000f;
+        public static final int list=0x7f060009;
+        public static final int login_button=0x7f060007;
+        public static final int menuadsremove=0x7f060011;
+        public static final int password=0x7f060005;
+        public static final int username=0x7f060004;
     }
     public static final class layout {
-        public static final int main=0x7f030000;
-        public static final int mobiadslist=0x7f030001;
-        public static final int mobiadsmain=0x7f030002;
-        public static final int mobiadsnewadslist=0x7f030003;
-        public static final int news_entry_list_item=0x7f030004;
+        public static final int ads_entry_list_item=0x7f030000;
+        public static final int main=0x7f030001;
+        public static final int mobiadslist=0x7f030002;
+        public static final int mobiadsmain=0x7f030003;
+        public static final int mobiadsnewadslist=0x7f030004;
+    }
+    public static final class menu {
+        public static final int menuads=0x7f050000;
     }
     public static final class string {
         public static final int alert_dialog_cancel=0x7f040004;
@@ -59,6 +63,7 @@ public final class R {
         public static final int error_dialog_connection_error=0x7f040005;
         public static final int error_dialog_userpwd_error=0x7f040006;
         public static final int hello=0x7f040000;
+        public static final int menuads_remove=0x7f04001e;
         public static final int new_ads=0x7f040001;
         public static final int password=0x7f040008;
         public static final int remote_service_content_empty_notification=0x7f040015;
diff --git a/Android/MobiAds/res/layout/ads_entry_list_item.xml b/Android/MobiAds/res/layout/ads_entry_list_item.xml
new file mode 100644 (file)
index 0000000..13a01c3
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Layout for individual ads entries in a list -->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical">
+    
+    <!-- Icon shown next to the title/text -->
+    <ImageView
+        android:id="@+id/ads_entry_icon"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentLeft="true"
+        android:padding="3dp"
+        android:orientation="vertical"
+        android:contentDescription="@string/desc"/>
+    
+    <!-- Title of the ads entry -->
+    <TextView
+        android:id="@+id/ads_entry_title"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_toRightOf="@id/ads_entry_icon"
+        android:layout_alignTop="@id/ads_entry_icon"
+           android:layout_margin="5dp"
+        android:textSize="14sp"
+        android:textStyle="bold" />
+    
+    <!-- Text of our entry -->
+    <TextView
+        android:id="@+id/ads_entry_text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignLeft="@id/ads_entry_title"
+        android:layout_below="@id/ads_entry_title" 
+        android:textSize="12sp" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/Android/MobiAds/res/layout/news_entry_list_item.xml b/Android/MobiAds/res/layout/news_entry_list_item.xml
deleted file mode 100644 (file)
index 13a01c3..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Layout for individual ads entries in a list -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:orientation="vertical">
-    
-    <!-- Icon shown next to the title/text -->
-    <ImageView
-        android:id="@+id/ads_entry_icon"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentLeft="true"
-        android:padding="3dp"
-        android:orientation="vertical"
-        android:contentDescription="@string/desc"/>
-    
-    <!-- Title of the ads entry -->
-    <TextView
-        android:id="@+id/ads_entry_title"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_toRightOf="@id/ads_entry_icon"
-        android:layout_alignTop="@id/ads_entry_icon"
-           android:layout_margin="5dp"
-        android:textSize="14sp"
-        android:textStyle="bold" />
-    
-    <!-- Text of our entry -->
-    <TextView
-        android:id="@+id/ads_entry_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignLeft="@id/ads_entry_title"
-        android:layout_below="@id/ads_entry_title" 
-        android:textSize="12sp" />
-
-</RelativeLayout>
\ No newline at end of file
index 9467d9d..d1b7991 100644 (file)
@@ -1,34 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
-      <item android:id="@+id/menuads"
-          android:title="string"
-          android:titleCondensed="string"
-          android:icon="@[package:]drawable/drawable_resource_name"
-          android:onClick="method name"
-          android:showAsAction=["ifRoom" | "never" | "withText" | "always" | "collapseActionView"]
-          android:actionLayout="@[package:]layout/layout_resource_name"
-          android:actionViewClass="class name"
-          android:actionProviderClass="class name"
+      <item android:id="@+id/menuadsremove"
+          android:title="@string/menuads_remove"
+          android:titleCondensed="@string/menuads_remove"
+          android:showAsAction="never"
           android:alphabeticShortcut="string"
           android:numericShortcut="string"
-          android:checkable=["true" | "false"]
-          android:visible=["true" | "false"]
-          android:enabled=["true" | "false"]
-          android:menuCategory=["container" | "system" | "secondary" | "alternative"]
-          android:orderInCategory="integer" />
-    <group android:id="@[+][package:]id/resource name"
-           android:checkableBehavior=["none" | "all" | "single"]
-           android:visible=["true" | "false"]
-           android:enabled=["true" | "false"]
-           android:menuCategory=["container" | "system" | "secondary" | "alternative"]
-           android:orderInCategory="integer" >
-        <item />
-    </group>
-    <item >
-        <menu>
-          <item />
-        </menu>
-    </item>
-    
-
+          android:checkable="false"
+          android:visible="true"
+          android:enabled="true" />
 </menu>
\ No newline at end of file
index d5ed866..123453f 100644 (file)
@@ -31,4 +31,5 @@
     <string name="user_agent_web_service">MobieAds/1.0</string>
     <string name="encoded_web_service">UTF-8</string>
     <string name="desc">description</string>
+    <string name="menuads_remove">Remove</string>
 </resources>
\ No newline at end of file
index 9befd15..064e0cc 100644 (file)
@@ -108,6 +108,7 @@ public class MobiAdsMainActivity extends Activity {
     public void onClickListLocalAds(View v) {
        Intent intent = new Intent("android.intent.action.MOBIADSLIST").
                                setComponent(new ComponentName("de.android.mobiads", "de.android.mobiads.list.MobiAdsListActivity"));
+       intent.putExtra("login", false);
                this.startActivity(intent);
     }
 }
index 4237189..06ff45a 100644 (file)
@@ -290,6 +290,7 @@ public class MobiAdsBatch {
                                                values.put(Indexer.Index.COLUMN_NAME_PATH, (String) objects.get("id"));
                                                values.put(Indexer.Index.COLUMN_NAME_TEXT, (String) objects.get("text"));
                                                values.put(Indexer.Index.COLUMN_NAME_URL, (String) objects.get("link"));
+                                               values.put(Indexer.Index.COLUMN_NAME_AD_NAME, (String) objects.get("adname"));
                                                values.put(Indexer.Index.COLUMN_NAME_IS_READ, new Integer(0));
                                                //This method may throw SQLiteException (as a RunTimeException). So, without a try/catch block
                                                //there could be a leaked cursor...
index 30cb3c3..f5492e2 100644 (file)
@@ -11,11 +11,15 @@ public final class AdsEntry {
        private final String title;
        private final String text;
        private final Bitmap icon;
+       private final int idAd;
+       private final String URL;
 
-       public AdsEntry(final String title, final String text, final Bitmap icon) {
+       public AdsEntry(final String title, final String text, final Bitmap icon, final int idAd, final String URL) {
                this.title = title;
                this.text = text;
                this.icon = icon;
+               this.idAd = idAd;
+               this.URL = URL;
        }
 
        /**
@@ -39,4 +43,17 @@ public final class AdsEntry {
                return icon;
        }
 
+       /**
+        * @return Ad unique identifier of this ads entry
+        */
+       public int getIdAd() {
+               return idAd;
+       }
+       
+       /**
+        * @return URL matching this ad.
+        */
+       public String getURL() {
+               return URL;
+       }
 }
index 26990ad..0d4dffb 100644 (file)
@@ -14,11 +14,11 @@ import android.widget.TextView;
  */
 public final class AdsEntryAdapter extends ArrayAdapter<AdsEntry> {
 
-       private final int newsItemLayoutResource;
+       private final int adsItemLayoutResource;
 
-       public AdsEntryAdapter(final Context context, final int newsItemLayoutResource) {
+       public AdsEntryAdapter(final Context context, final int adsItemLayoutResource) {
                super(context, 0);
-               this.newsItemLayoutResource = newsItemLayoutResource;
+               this.adsItemLayoutResource = adsItemLayoutResource;
        }
 
        @Override
@@ -51,7 +51,7 @@ public final class AdsEntryAdapter extends ArrayAdapter<AdsEntry> {
                        final LayoutInflater inflater = (LayoutInflater)context.getSystemService
                      (Context.LAYOUT_INFLATER_SERVICE);
                        
-                       workingView = inflater.inflate(newsItemLayoutResource, null);
+                       workingView = inflater.inflate(adsItemLayoutResource, null);
                } else {
                        workingView = convertView;
                }
index 45a4300..2879512 100644 (file)
@@ -6,6 +6,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityManager.RunningServiceInfo;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -16,20 +18,26 @@ import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
+import android.os.Bundle;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ListView;
+import de.android.mobiads.MobiAdsService;
 import de.android.mobiads.R;
 import de.android.mobiads.provider.Indexer;
 
 public class MobiAdsListActivity extends Activity {
        private static final String TAG = "MobiAdsListActivity";
+       private AdsEntryAdapter newsEntryAdapter;
        
+
     @Override
     public void onResume() {
         super.onResume();
@@ -37,7 +45,7 @@ public class MobiAdsListActivity extends Activity {
         
         // Setup the list view
         final ListView newsEntryListView = (ListView) findViewById(R.id.list);
-        final AdsEntryAdapter newsEntryAdapter = new AdsEntryAdapter(this, R.layout.news_entry_list_item);
+        newsEntryAdapter = new AdsEntryAdapter(this, R.layout.ads_entry_list_item);
         newsEntryListView.setAdapter(newsEntryAdapter);
         
         this.registerForContextMenu(newsEntryListView);
@@ -51,7 +59,7 @@ public class MobiAdsListActivity extends Activity {
 
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-                               Uri uri = Uri.parse(newsEntryAdapter.getItem(position).getTitle());
+                               Uri uri = Uri.parse(newsEntryAdapter.getItem(position).getURL());
                                startActivity(new Intent(Intent.ACTION_VIEW, uri));
                        }
         });
@@ -89,8 +97,10 @@ public class MobiAdsListActivity extends Activity {
                                                        }
                                                }
                                        }
-                                       entries.add(new AdsEntry(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_URL)), 
-                                                       cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_TEXT)), bitMap));                       
+                                       entries.add(new AdsEntry(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_AD_NAME)), 
+                                                       cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_TEXT)), bitMap,
+                                                       cursor.getInt(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_ID_AD)),
+                                                       cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_URL))));                        
                                        if (cursor.getInt(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_IS_READ)) == 0)
                                        {
                                                values.put(Indexer.Index.COLUMN_NAME_IS_READ, new Integer(1));
@@ -104,7 +114,9 @@ public class MobiAdsListActivity extends Activity {
                                cursor.close();
                }
        
-       showNotification(0, 0, getText(R.string.remote_service_content_empty_notification));
+       if (this.isMyServiceRunning()) {
+               showNotification(0, 0, getText(R.string.remote_service_content_empty_notification));
+       }
        
        return entries;
     }
@@ -116,6 +128,37 @@ public class MobiAdsListActivity extends Activity {
         inflater.inflate(R.menu.menuads, menu);
     }
 
+    @Override
+    public boolean onContextItemSelected(MenuItem item) {
+        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
+        switch (item.getItemId()) {
+            case R.id.menuadsremove:
+               removeAd(info.position);
+                return true;
+            default:
+                return super.onContextItemSelected(item);
+        }
+    }
+    
+    public void removeAd(int position){
+       AdsEntry entry = this.newsEntryAdapter.getItem(position);
+       int idAd = entry.getIdAd();
+       Uri uriDelete = Uri.parse("content://" + "de.android.mobiads.provider" + "/" + "indexer" + "/idad/" + idAd);
+       
+       getContentResolver().delete(uriDelete, null, null);
+       this.newsEntryAdapter.remove(entry);
+       this.newsEntryAdapter.notifyDataSetChanged();
+    }
+    
+    private boolean isMyServiceRunning() {
+        ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+        for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
+            if (MobiAdsService.class.getName().equals(service.service.getClassName())) {
+                return true;
+            }
+        }
+        return false;
+    }
     
     public void showNotification(final int level, final int noReadAds, CharSequence contentText) {        
        NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
index 60f0910..fd42e16 100644 (file)
@@ -5,12 +5,16 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+
+import de.android.mobiads.MobiAdsService;
 import de.android.mobiads.R;
 import de.android.mobiads.provider.Indexer;
 import android.app.Activity;
+import android.app.ActivityManager;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.app.ActivityManager.RunningServiceInfo;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
@@ -34,7 +38,7 @@ public class MobiAdsNewAdsActivity extends Activity {
                
                // Setup the list view
                final ListView newsEntryListView = (ListView) findViewById(R.id.list);
-               final AdsEntryAdapter newsEntryAdapter = new AdsEntryAdapter(this, R.layout.news_entry_list_item);
+               final AdsEntryAdapter newsEntryAdapter = new AdsEntryAdapter(this, R.layout.ads_entry_list_item);
                newsEntryListView.setAdapter(newsEntryAdapter);
                
                // Populate the list, through the adapter. Should I populate the whole list right now? I do not think so...
@@ -86,8 +90,10 @@ public class MobiAdsNewAdsActivity extends Activity {
                                                                }
                                                        }
                                                }
-                                               entries.add(new AdsEntry(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_URL)), 
-                                                               cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_TEXT)), bitMap));
+                                               entries.add(new AdsEntry(cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_AD_NAME)), 
+                                                               cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_TEXT)), bitMap,
+                                                               cursor.getInt(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_ID_AD)),
+                                                               cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_URL))));
 
                                                
                                                cursor.getString(cursor.getColumnIndexOrThrow(Indexer.Index.COLUMN_NAME_PATH));
@@ -101,12 +107,23 @@ public class MobiAdsNewAdsActivity extends Activity {
                                        cursor.close();
                        }
                
-
-               showNotification(0, 0, getText(R.string.remote_service_content_empty_notification));
+               if (this.isMyServiceRunning()) {
+                       showNotification(0, 0, getText(R.string.remote_service_content_empty_notification));
+               }
                
                return entries;
            }
            
+           private boolean isMyServiceRunning() {
+               ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
+               for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
+                   if (MobiAdsService.class.getName().equals(service.service.getClassName())) {
+                       return true;
+                   }
+               }
+               return false;
+           }
+           
            public void showNotification(final int level, final int noReadAds, CharSequence contentText) {        
                NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
                Intent intent =  new Intent(this, MobiAdsNewAdsActivity.class);
index 5e3e866..c44756c 100644 (file)
@@ -55,6 +55,13 @@ public final class Indexer {
         public static final String COLUMN_NAME_IS_READ = "isRead";
         
         /**
+         * Column name for the Sqlite3 integer as boolean field. <br>
+         * It let us know if the ad was already read by the user or not.
+         * <P>Type: TEXT</P>
+         */
+        public static final String COLUMN_NAME_AD_NAME = "adName";
+        
+        /**
          * The default sort order for this table
          */
         public static final String DEFAULT_SORT_ORDER = Index._ID;
index aa0d270..bb88fc3 100644 (file)
@@ -29,9 +29,10 @@ public class IndexerOpenHelper extends SQLiteOpenHelper {
                                + Indexer.Index._ID + " INTEGER PRIMARY KEY, "
                                + Indexer.Index.COLUMN_NAME_ID_AD + " INTEGER" + " UNIQUE" + " NOT NULL, "
                                + Indexer.Index.COLUMN_NAME_PATH + " TEXT(15)" + " UNIQUE" + " NOT NULL, "
-                               + Indexer.Index.COLUMN_NAME_URL + " TEXT(2000)" + " NOT NULL, "
-                               + Indexer.Index.COLUMN_NAME_TEXT + " TEXT(255)" + " NOT NULL, "
-                               + Indexer.Index.COLUMN_NAME_IS_READ + " INTEGER" + " NOT NULL "
+                               + Indexer.Index.COLUMN_NAME_URL + " TEXT(3000)" + " NOT NULL, "
+                               + Indexer.Index.COLUMN_NAME_TEXT + " TEXT(500)" + " NOT NULL, "
+                               + Indexer.Index.COLUMN_NAME_IS_READ + " INTEGER" + " NOT NULL, "
+                               + Indexer.Index.COLUMN_NAME_AD_NAME + " TEXT(255)" + " NOT NULL "
                                + ");");
        }
 
index caebab5..fc0387d 100644 (file)
@@ -80,6 +80,8 @@ public class IndexerProvider extends ContentProvider {
         sIndexerProjectionMap.put(Indexer.Index.COLUMN_NAME_URL, Indexer.Index.COLUMN_NAME_URL);
         
         sIndexerProjectionMap.put(Indexer.Index.COLUMN_NAME_IS_READ, Indexer.Index.COLUMN_NAME_IS_READ);
+        
+        sIndexerProjectionMap.put(Indexer.Index.COLUMN_NAME_AD_NAME, Indexer.Index.COLUMN_NAME_AD_NAME);
     }
  
     
@@ -158,7 +160,21 @@ public class IndexerProvider extends ContentProvider {
                                        selectionArgs                  // The incoming where clause values.
                        );
                        break;
-
+                       
+               case INDEXER_IDAD:
+                       finalWhere = 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);
+                       if (selection != null) {
+                               finalWhere = finalWhere + " AND " + selection;
+                       }
+                       count = db.delete(
+                                       Indexer.Index.TABLE_NAME,  // The database table name.
+                                       finalWhere,                // The final WHERE clause
+                                       selectionArgs                  // The incoming where clause values.
+                       );
+                       break;
                default:
                        throw new IllegalArgumentException("Unknown URI " + uri);
         }
@@ -223,8 +239,9 @@ public class IndexerProvider extends ContentProvider {
                (values.containsKey(Indexer.Index.COLUMN_NAME_ID_AD) == false) || 
                (values.containsKey(Indexer.Index.COLUMN_NAME_TEXT) == false) || 
                (values.containsKey(Indexer.Index.COLUMN_NAME_URL) == false) ||
+               (values.containsKey(Indexer.Index.COLUMN_NAME_AD_NAME) == false) ||
                (values.containsKey(Indexer.Index.COLUMN_NAME_IS_READ) == false)){
-               throw new SQLException("Missed parameter. Failed to insert row into " + uri);
+                       throw new SQLException("Missed parameter. Failed to insert row into " + uri);
         }      
         
         // Opens the database object in "write" mode.