== Adding the Content Provider Package ==
== Adding the Content Provider Package ==
−The next step is to add a new package to the DatabaseProvider project into which the content provider class will be created. Add this new package by navigating within the Project tool window to src -> main -> java, right clicking on the java entry and selecting the New -> Package menu option. In the New Package dialog, enter the following package name into the name field before clicking on the OK button:
+The next step is to add a new package to the DatabaseProvider project into which the content provider class will be created. Add this new package by navigating within the Project tool window to DatabaseProvider - > app -> src -> main -> java, right clicking on the java entry and selecting the New -> Package menu option. In the New Package dialog, enter the following package name into the name field before clicking on the OK button:
<pre>
<pre>
−com.ebookfrenzy.database.database.provider
+com.ebookfrenzy.database.provider
</pre>
</pre>
−[[Image:android_studio_new_package_added.png|A new package added to an Android Studio project]]
+[[Image:android_studio_new_package_added2.png|A new package added to an Android Studio project]]
Figure 42-1
Figure 42-1
<pre>
<pre>
−com.ebookfrenzy.database.database.provider.MyContentProvider
+com.ebookfrenzy.database.provider.MyContentProvider
</pre>
</pre>
<pre>
<pre>
−package com.ebookfrenzy.database.database.provider;
+package com.ebookfrenzy.database.provider;
import android.content.ContentProvider;
import android.content.ContentProvider;
<pre>
<pre>
−package com.ebookfrenzy.database.database.provider;
+package com.ebookfrenzy.database.provider;
import android.content.ContentProvider;
import android.content.ContentProvider;
private static final String AUTHORITY =
private static final String AUTHORITY =
− "com.ebookfrenzy.database.database.provider.MyContentProvider";
+ "com.ebookfrenzy.database.provider.MyContentProvider";
private static final String PRODUCTS_TABLE = "products";
private static final String PRODUCTS_TABLE = "products";
public static final Uri CONTENT_URI =
public static final Uri CONTENT_URI =
<pre>
<pre>
−package com.ebookfrenzy.database.database.provider;
+package com.ebookfrenzy.database.provider;
import android.content.ContentProvider;
import android.content.ContentProvider;
private static final String AUTHORITY =
private static final String AUTHORITY =
− "com.ebookfrenzy.database.database.provider.MyContentProvider";
+ "com.ebookfrenzy.database.provider.MyContentProvider";
private static final String PRODUCTS_TABLE = "products";
private static final String PRODUCTS_TABLE = "products";
public static final Uri CONTENT_URI =
public static final Uri CONTENT_URI =
private static final String AUTHORITY =
private static final String AUTHORITY =
− "com.ebookfrenzy.database.database.provider.MyContentProvider";
+ "com.ebookfrenzy.database.provider.MyContentProvider";
private static final String PRODUCTS_TABLE = "products";
private static final String PRODUCTS_TABLE = "products";
public static final Uri CONTENT_URI =
public static final Uri CONTENT_URI =
<pre>
<pre>
−package com.ebookfrenzy.database.database.provider;
+package com.ebookfrenzy.database.provider;
−import com.ebookfrenzy.database.database.MyDBHandler;
+import com.ebookfrenzy.database.MyDBHandler;
import android.content.ContentProvider;
import android.content.ContentProvider;
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
− package="com.ebookfrenzy.database.database" >
+ package="com.ebookfrenzy.database" >
<application
<application
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme" >
<activity
<activity
− android:name="com.ebookfrenzy.database.database.DatabaseActivity"
+ android:name=".DatabaseActivity"
android:label="@string/app_name" >
android:label="@string/app_name" >
<intent-filter>
<intent-filter>
</activity>
</activity>
Exception encountered, of type "Error"
[40b34363] /index.php?diff=17220&oldid=16968&title=An_Android_Studio_Content_Provider_Example Error from line 434 of /var/www/techotopia/includes/diff/DairikiDiff.php: Call to undefined function each()
Backtrace:
#0 /var/www/techotopia/includes/diff/DairikiDiff.php(544): DiffEngine->diag()
#1 /var/www/techotopia/includes/diff/DairikiDiff.php(344): DiffEngine->compareSeq()
#2 /var/www/techotopia/includes/diff/DairikiDiff.php(227): DiffEngine->diffLocal()
#3 /var/www/techotopia/includes/diff/DairikiDiff.php(721): DiffEngine->diff()
#4 /var/www/techotopia/includes/diff/DairikiDiff.php(859): Diff->__construct()
#5 /var/www/techotopia/includes/diff/DairikiDiff.php(980): MappedDiff->__construct()
#6 /var/www/techotopia/includes/diff/TableDiffFormatter.php(194): WordLevelDiff->__construct()
#7 /var/www/techotopia/includes/diff/DiffFormatter.php(140): TableDiffFormatter->changed()
#8 /var/www/techotopia/includes/diff/DiffFormatter.php(82): DiffFormatter->block()
#9 /var/www/techotopia/includes/diff/DifferenceEngine.php(881): DiffFormatter->format()
#10 /var/www/techotopia/includes/diff/DifferenceEngine.php(797): DifferenceEngine->generateTextDiffBody()
#11 /var/www/techotopia/includes/diff/DifferenceEngine.php(728): DifferenceEngine->generateContentDiffBody()
#12 /var/www/techotopia/includes/diff/DifferenceEngine.php(662): DifferenceEngine->getDiffBody()
#13 /var/www/techotopia/includes/diff/DifferenceEngine.php(632): DifferenceEngine->getDiff()
#14 /var/www/techotopia/includes/diff/DifferenceEngine.php(453): DifferenceEngine->showDiff()
#15 /var/www/techotopia/includes/page/Article.php(797): DifferenceEngine->showDiffPage()
#16 /var/www/techotopia/includes/page/Article.php(508): Article->showDiffPage()
#17 /var/www/techotopia/includes/actions/ViewAction.php(44): Article->view()
#18 /var/www/techotopia/includes/MediaWiki.php(490): ViewAction->show()
#19 /var/www/techotopia/includes/MediaWiki.php(287): MediaWiki->performAction()
#20 /var/www/techotopia/includes/MediaWiki.php(714): MediaWiki->performRequest()
#21 /var/www/techotopia/includes/MediaWiki.php(508): MediaWiki->main()
#22 /var/www/techotopia/index.php(41): MediaWiki->run()
#23 {main}