I am trying to fetch image URL saved in my local sql dB and display it in the image view but some how there is error on my image being null.. i am already reading name of the image and it works perfect but the image url cant not be displayed, As the URl is being fetch its in String format so need to b decoded first to be displayed.. is there a way to decode it when my cursor fetch URL and decode it send it in list-View for display.
please see the code below: ----------->>>>>>>>>>the class where the fetched data is being displayed
public class NewsFeed_Viewoverlay extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.newsfeed_viewoverlay);
DatabaseHelper helper;
ImageView list_image;
VideoView list_video;
helper= new DatabaseHelper(this.getApplicationContext());
list_image= (ImageView) findViewById(R.id.list_image);
list_video = (VideoView)findViewById(R.id.list_video);
//-------------------------------------------------------------------->>>>>>>>XXXXXXXXXXX<<<<<<<<<<-----------------------
Cursor cursor = helper.getCursor();
startManagingCursor(cursor);
//setup for MApping in view fields
String [] fromFieldNames=new String[]{helper.KEY_NAME,helper.KEY_IMAGE};
//list_image.setImageBitmap(BitmapFactory.decodeFile(helper.KEY_IMAGE));
// list_video.setVideoURI(Uri.parse(helper.KEY_FILE));
int[] toViewID= new int[]{R.id.title, R.id.list_image};
SimpleCursorAdapter myadaptor= new SimpleCursorAdapter(this, R.layout.list_row, cursor,fromFieldNames,toViewID );
ListView mylist= (ListView)findViewById(R.id.list);
mylist.setAdapter(myadaptor);
Log.i("READ-->Path in DB->", "" + helper.KEY_NAME + helper.KEY_IMAGE);
}
---------------------->>>>>>>THE Database class for cursor----------------
public void Insert(String imgpath, String vidPath, String name ) throws SQLException {
db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_IMAGE, imgpath);
values.put(KEY_FILE, vidPath);
values.put(KEY_NAME,name);
db.insert(TABLE_Images, null, values);
db.close();
Log.i("INSERTED-->Path in DB->", "" + imgpath);
Log.i("INSERTED-->Path in DB->", "" + vidPath);
Log.i("INSERTED-->Path in DB->", "" + name);
}
public static final String[] KEY= new String[] {KEY_ID,KEY_NAME,KEY_IMAGE,KEY_FILE};
public Cursor getCursor()
{
String where=null; ContentResolver resolver;
db= this.getReadableDatabase();
//db.rawQuery("select image , name from images",null);
//Cursor cursor = db.rawQuery("select _id, name from images",null);
Cursor cursor= db.query(true,TABLE_Images,KEY,where,null,null,null,null,null,null);
if (cursor!=null)
{
cursor.moveToFirst();
}
return cursor;
}
please refer any links or at-least tell me if there is alternative.
Aucun commentaire:
Enregistrer un commentaire