Comment créer une Table avec une colonne de type BLOB dans un DBAdapter

J'ai un mondial DBAdapter et aussi pour chaque Table une. Dans mon global DB-Adaptateur, j'ai ajouté du type "BLOB" de la colonne. Mais je ne comprends pas ce que je dois changer dans mon DBAdapter pour la Table spécifique. Ce que j'ai besoin de changement qu'il fonctionne également avec le type BLOB.

Donc, ici, vous allez:

Mondiale DBAdapter:

package de.retowaelchli.filterit.database;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import de.retowaelchli.filterit.database.ADFilterDBAdapter;
public class DBAdapter {
public static final String DATABASE_NAME = "filterit";
public static final int DATABASE_VERSION = 1;
public static final String CREATE_TABLE_ADFILTER = "create table adfilter (_id integer primary key autoincrement, "
+ ADFilterDBAdapter.NAME+","
+ ADFilterDBAdapter.KEYWORD+","
+ ADFilterDBAdapter.CACHE + ");";
private static final String CREATE_TABLE_SFILTER = "create table sfilter (_id integer primary key autoincrement, "
+SFilterDBAdapter.NAME+","
+SFilterDBAdapter.KEYWORD+","
+SFilterDBAdapter.SMILEY+ ");";
private static final String CREATE_TABLE_ADMESSAGES = "create table admessages (_id integer primary key autoincrement, "
+MessagesDBAdapter.PHONENUMBER+","
+MessagesDBAdapter.MESSAGE+ ");";
//HERE I CHANGED IT TO BLOB!
private static final String CREATE_TABLE_SMILEY = " create table smiley (_id integer primary key autoincrement, "
+SmileyDBAdapter.SOURCE+" BLOB ,"
+SmileyDBAdapter.INFO+ ");";
private final Context context; 
private DatabaseHelper DBHelper;
private SQLiteDatabase db;
/**
* Constructor
* @param ctx
*/
public DBAdapter(Context ctx)
{
this.context = ctx;
}
private static class DatabaseHelper extends SQLiteOpenHelper 
{
DatabaseHelper(Context context) 
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) 
{
db.execSQL(CREATE_TABLE_ADFILTER);
db.execSQL(CREATE_TABLE_SFILTER);
db.execSQL(CREATE_TABLE_ADMESSAGES);
db.execSQL(CREATE_TABLE_SMILEY);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, 
int newVersion) 
{               
// Adding any table mods to this guy here
}
} 
/**
* open the db
* @return this
* @throws SQLException
* return type: DBAdapter
*/
public DBAdapter open() throws SQLException 
{
this.DBHelper = new DatabaseHelper(this.context);
this.db = this.DBHelper.getWritableDatabase();
return this;
}
/**
* close the db 
* return type: void
*/
public void close() 
{
this.DBHelper.close();
}
}

C'est mon DBAdapter de ce Tableau:

package de.retowaelchli.filterit.database;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class SmileyDBAdapter {
public static final String ROW_ID = "_id";
public static final String SOURCE = "source";
public static final String INFO = "info";
private static final String DATABASE_TABLE = "admessages";
private DatabaseHelper mDbHelper;
private SQLiteDatabase mDb;
private final Context mCtx;
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DBAdapter.DATABASE_NAME, null, DBAdapter.DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
/**
* Constructor - takes the context to allow the database to be
* opened/created
* 
* @param ctx
*            the Context within which to work
*/
public SmileyDBAdapter(Context ctx) {
this.mCtx = ctx;
}
public SmileyDBAdapter open() throws SQLException {
this.mDbHelper = new DatabaseHelper(this.mCtx);
this.mDb = this.mDbHelper.getWritableDatabase();
return this;
}
/**
* close return type: void
*/
public void close() {
this.mDbHelper.close();
}
public long createSmiley(String source, String info ){
ContentValues initialValues = new ContentValues();
initialValues.put(SOURCE, source);
initialValues.put(INFO, info);
return this.mDb.insert(DATABASE_TABLE, null, initialValues);
}
public boolean deleteSmiley(long rowId) {
return this.mDb.delete(DATABASE_TABLE, ROW_ID + "=" + rowId, null) > 0; //$NON-NLS-1$
}
public Cursor getAllSmileys() {
return this.mDb.query(DATABASE_TABLE, new String[] { ROW_ID,
SOURCE, INFO }, null, null, null, null, null);
}
public Cursor getSmiley(long rowId) throws SQLException {
Cursor mCursor =
this.mDb.query(true, DATABASE_TABLE, new String[] { ROW_ID, SOURCE,
INFO }, ROW_ID + "=" + rowId, null, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
public boolean updateSmiley(long rowId, String source, String info,
String cache){
ContentValues args = new ContentValues();
args.put(SOURCE, source);
args.put(INFO, info);
return this.mDb.update(DATABASE_TABLE, args, ROW_ID + "=" + rowId, null) >0; 
}
}

Ce que je dois changer dans mon SmileyDBAdapter pour le porter de travail. Qu'il prend en charge le type BLOB. Im vraiment frustré après avoir essayé ce pour serval heures -.-

Thx d'Avance pour votre Réponse

En Ce Qui Concerne Meilleur

safari

Ce n'est pas de travail?! Quel est le problème exact? Je vois un DBAdapter qui est en fait utilisé nulle part...

OriginalL'auteur safari | 2011-09-22