The addresses vary because they're different objects.  You need to
dump some of the actual byte arrays to see if they're different.  You
could even write code to compare input and output.

On Dec 21, 6:40 pm, Muhammad Amiral <4mi...@gmail.com> wrote:
> Hi all.
>
> I would like to save an image from Internet to database, I've tried to
> convert images into bytearray and store them in a database.
>
> Here my code:
>
> this is to created table:
>
> > myDB.execSQL("CREATE TABLE IF NOT EXISTS News (Title VARCHAR(20), imageUrl
> > BLOB, publishDate TIMESTAMP, expiredDate TIMESTAMP);");
>
> and this is my Method to Insert table:
>
> public void insertlistNews(String city,byte[] newsImageUrl, String
>
> > publishDate, String expiredDate){
>
> try {
>
>  myDB.execSQL("INSERT INTO News (title,imageUrl,publishDate,expiredDate)"
>
>   + " VALUES ('" + city + "','" + imageUrl + "','" + publishDate+ "','" +
>
> > expiredDate"');");
>
> Log.i("Android", "Table created");
>
> } catch (Exception e) {
>
> Log.i("Android", "No Table created" + e.getMessage());
>
> }
>
> //for check bytearray in database
>
> Log.i("Android", "Image saved in database: "+ urlFrontImage);
>
> }
>
> The last my method for getNews from db:
>
> public ArrayList getAllNews() {
>
>  ArrayList news = new ArrayList<News>();
>
>  Cursor c = myDB.rawQuery("SELECT title,imageUrl,publishDate,expiredDate
>
> FROM News WHERE publishedDate <= DATETIME() and expiredDate >= DATETIME()
>
> > ORDER BY publishedDate DESC;", null);
>
>  if (c != null) {
>
>   c.moveToFirst();
>
>   int count = 0;
>
>   while (c.moveToNext()) {
>
>    if (count == 0)
>
>       c.moveToFirst();
>
>    String title = c.getString(0);
>
>    byte[] image = c.getBlob(1);
>
>    String publishDate = c.getString(2);
>
>    String expiredDate = c.getString(3);
>
> >    NewsItem nl = new NewsItem(title, image, publishDate, expiredDate);
>
>    Log.i("Android", "Image get from db: "+image);
>
>    news.add(nl);
>
>    count++;
>
>   }
>
>  }
>
> return news;
>
> }
>
> when I run it the newsimage not appear and the Log like this:
>
> 12-22 00:11:49.362: INFO/Android(307): Image saved in database: [...@437cbdb8
>
> 12-22 00:11:51.052: INFO/Android(307): Image saved in database: [...@437db710
>
> 12-22 00:11:51.862: INFO/Android(307): Image saved in database: [...@437c1338
>
> > 12-22 00:12:07.962: INFO/Android(307): Image get from db: [...@4382d370
>
> 12-22 00:12:07.982: INFO/Android(307): Image get from db db: [...@4382d9c0
>
> 12-22 00:12:07.992: INFO/Android(307): Image get from db: [...@4382e0e0
>
> why results can vary between the insert and getNews?
>
> --
> Best Regards
>
> =====
> Amiral

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to