Ikuti tutorial ini untuk membaca gambar dari folder aset. Berikut ini tautannya Tautan untuk membaca gambar dari folder Aset Kelas konten diperluas dari ContentProvider tetapi saya mendapatkan kesalahan di Baris pertama. Kesalahan ini ada di baris pertama Baris Kelas Konten. Tolong beri tahu saya hal-hal apa saja yang perlu saya terapkan di Kelas Konten1 .Jawa
Multiple markers at this line
- The type Contentclass1 must implement the inherited abstract method ContentProvider.onCreate()
- The type Contentclass1 must implement the inherited abstract method ContentProvider.delete(Uri, String, String[])
- The type Contentclass1 must implement the inherited abstract method ContentProvider.query(Uri, String[], String, String[],
String)
- The type Contentclass1 must implement the inherited abstract method ContentProvider.getType(Uri)
- The type Contentclass1 must implement the inherited abstract method ContentProvider.update(Uri, ContentValues, String,
String[])
- The type Contentclass1 must implement the inherited abstract method ContentProvider.insert(Uri, ContentValues)
Kontenkelas1.java
package com.example.shareima;
import java.io.FileNotFoundException;
import java.io.IOException;
import android.content.ContentProvider;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.net.Uri;
public class Contentclass1 extends ContentProvider
{
@Override
public AssetFileDescriptor openAssetFile(Uri uri,String mode) throws FileNotFoundException {
AssetManager am = getContext().getAssets();
String file_name = uri.getLastPathSegment();
if(file_name == null)
throw new FileNotFoundException();
AssetFileDescriptor afd = null;
try {
afd = am.openFd(file_name);
} catch (IOException e) {
e.printStackTrace();
}
return afd;//super.openAssetFile(uri, mode);
}
}
Manifes.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shareima"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.shareima.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:name=".Contentclass1"
android:authorities="com.example.shareima"/>
</application>
</manifest>