如何保存图像URL和图像URL从Android中的SQL Server读取..?

时间:2017-07-31 11:07:39

标签: android sql-server-2008 url android-imageview imageurl

如何使用android应用程序在Sql server数据库中保存图像(图像URL),我在sql web server 2008中存储/保存base64格式的图像,我想将图像路径(URL)存储到数据库我怎么做搜索但是没有进入带有android概念的SQL Server请帮助我

我的代码是:

Gallery select :
````````````````
     private void onSelectFromGalleryResult(Intent data) {
           // Uri selectedImageUri = data.getData();
           // saveFile(data);
            Bitmap bm = null;
            if (data != null) {
                try {
                    bm = MediaStore.Images.Media.getBitmap(Admin.this.getApplicationContext().getContentResolver(), data.getData());
                    imgadminview.setImageBitmap(bm);
                    int bitmapByteCount= BitmapCompat.getAllocationByteCount(bm);
                    System.out.print(bitmapByteCount);
                    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                    bm.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
                    byteArray = bytes.toByteArray();
                    encodedImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
                    btarray = Base64.decode(encodedImage, Base64.DEFAULT);
                    bmimage = BitmapFactory.decodeByteArray(byteArray, 0, btarray.length);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            imgadminview.setImageBitmap(bm);
        }



Insert Query :
``````````````

       @Override
            protected String doInBackground(String... params) {

                try {
                    connectionClass = new ConnectionClass();
                    Connection con = connectionClass.CONN();
                    if (con == null) {
                        Y = "SQL Connection Error";
                    }


                    String query = "Insert into FD_ItemMaster(CatId,ItemName,Description,Image)values('"+catid+"','"+itemname+"','"+desc+"','"+img1+"')";

                    PreparedStatement preparedStatement = con.prepareStatement(query);
                    preparedStatement.executeUpdate();
                    Y = "Saved Successfully";
                    issucess = true;
                } catch (Exception ex) {
                    issucess = false;
                    Y = ex.toString();
                }
                return Y;
            }

0 个答案:

没有答案