ทำตามบทช่วยสอนนี้เพื่ออ่านรูปภาพจากโฟลเดอร์เนื้อหา นี่คือลิงค์ ลิงก์สำหรับอ่านรูปภาพจากโฟลเดอร์ Assets Contentclass ขยายจาก ContentProvider แต่ฉันได้รับข้อผิดพลาดในบรรทัดแรก ข้อผิดพลาดนี้อยู่ในบรรทัดแรกสุด Contentclass1 Line โปรดแจ้งให้เราทราบว่าฉันต้องดำเนินการอะไรบ้างใน Contentclass1 .java
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)
Contentclass1.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);
}
}
Manifest.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>