</intent-filter>
</activity>
+ <provider
+ android:authorities="de.android.test3.provider"
+ android:enabled="true"
+ android:exported="false"
+ android:grantUriPermissions="false"
+ android:icon="@drawable/ic_launcher"
+ android:initOrder="1"
+ android:label="@string/app_name"
+ android:multiprocess="false"
+ android:name=".IndexerProvider"
+ android:permission="android.permission.MOBIADS"
+ android:readPermission="android.permission.READ_MOBIADS"
+ android:syncable="false"
+ android:writePermission="android.permission.WRITE_MOBIADS" >
+ <grant-uri-permission
+ android:path="string"
+ android:pathPattern="string"
+ android:pathPrefix="string" />
+ </provider>
+ <!--
+ <provider
+ android:process="string" When having my service, here I should write the service process name
+ </provider>-->
+
</application>
</manifest>
\ No newline at end of file
--- /dev/null
+package de.android.test3;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class IndexerOpenHelper extends SQLiteOpenHelper {
+ private static final String DBNAME = "mobiads";
+ private static final int DATABASE_VERSION = 1;
+ private static final String TABLE_NAME = "indexer";
+ private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_NAME +
+ "(_ID INTEGER NOT NULL, " +
+ "PATH TEXT(15) NOT NULL, " +
+ "PRIMARY KEY (_ID), " +
+ "UNIQUE (PATH), " + ")";
+
+ IndexerOpenHelper(Context context) {
+ super(context, DBNAME, null, DATABASE_VERSION);
+ }
+
+
+ /*
+ * Creates the data repository. This is called when the provider attempts to open the
+ * repository and SQLite reports that it doesn't exist.
+ */
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(TABLE_CREATE);
+ }
+
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ }
+}
--- /dev/null
+/**
+ *
+ */
+package de.android.test3;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+
+/**
+ *
+ */
+public class IndexerProvider extends ContentProvider {
+ // Holds the database object
+ private SQLiteDatabase db;
+ /*
+ * Defines a handle to the database helper object. The MainDatabaseHelper class is defined
+ * in a following snippet.
+ */
+ private IndexerOpenHelper mOpenHelper;
+
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#delete(android.net.Uri, java.lang.String, java.lang.String[])
+ */
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#getType(android.net.Uri)
+ */
+ @Override
+ public String getType(Uri uri) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#insert(android.net.Uri, android.content.ContentValues)
+ */
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ /*
+ * Gets a writeable database. This will trigger its creation if it doesn't already exist.
+ *
+ */
+ db = mOpenHelper.getWritableDatabase();
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#onCreate()
+ */
+ @Override
+ public boolean onCreate() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#query(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String)
+ */
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection,
+ String[] selectionArgs, String sortOrder) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see android.content.ContentProvider#update(android.net.Uri, android.content.ContentValues, java.lang.String, java.lang.String[])
+ */
+ @Override
+ public int update(Uri uri, ContentValues values, String selection,
+ String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
JSONArray finalResult = new JSONArray(tokener);
for (int i = 0; i < finalResult.length(); i++) {
JSONObject objects = finalResult.getJSONObject(i);
- //Find out if that id is in the SQLITE database.
+ //Find out if that id is in the SQLite database.
downloadAds((Integer) objects.get("id"), (String)objects.get("domain"), (String)objects.get("link"));
}
}
}
} finally {
//instream will never be null in case of reaching this code, cause it was initialized outside try/catch block.
- //In case of exception here, it is thrown to the superior layer.
+ //In case of exception here, it is thrown to the upper layer.
instream.close();
}
}