久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='lUu5n'><tr id='lUu5n'><dt id='lUu5n'><q id='lUu5n'><span id='lUu5n'><b id='lUu5n'><form id='lUu5n'><ins id='lUu5n'></ins><ul id='lUu5n'></ul><sub id='lUu5n'></sub></form><legend id='lUu5n'></legend><bdo id='lUu5n'><pre id='lUu5n'><center id='lUu5n'></center></pre></bdo></b><th id='lUu5n'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='lUu5n'><tfoot id='lUu5n'></tfoot><dl id='lUu5n'><fieldset id='lUu5n'></fieldset></dl></div>

      <bdo id='lUu5n'></bdo><ul id='lUu5n'></ul>

    <small id='lUu5n'></small><noframes id='lUu5n'>

    <legend id='lUu5n'><style id='lUu5n'><dir id='lUu5n'><q id='lUu5n'></q></dir></style></legend>
  • <tfoot id='lUu5n'></tfoot>

        如何將圖像存儲在 SQLite 數(shù)據(jù)庫中

        How to store image in SQLite database(如何將圖像存儲在 SQLite 數(shù)據(jù)庫中)
          <bdo id='4RgxO'></bdo><ul id='4RgxO'></ul>
          <tfoot id='4RgxO'></tfoot>
            <i id='4RgxO'><tr id='4RgxO'><dt id='4RgxO'><q id='4RgxO'><span id='4RgxO'><b id='4RgxO'><form id='4RgxO'><ins id='4RgxO'></ins><ul id='4RgxO'></ul><sub id='4RgxO'></sub></form><legend id='4RgxO'></legend><bdo id='4RgxO'><pre id='4RgxO'><center id='4RgxO'></center></pre></bdo></b><th id='4RgxO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4RgxO'><tfoot id='4RgxO'></tfoot><dl id='4RgxO'><fieldset id='4RgxO'></fieldset></dl></div>
                <tbody id='4RgxO'></tbody>
            1. <small id='4RgxO'></small><noframes id='4RgxO'>

                <legend id='4RgxO'><style id='4RgxO'><dir id='4RgxO'><q id='4RgxO'></q></dir></style></legend>
                • 本文介紹了如何將圖像存儲在 SQLite 數(shù)據(jù)庫中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  在我的應(yīng)用程序中,我正在從圖庫上傳一張圖片,我想將此圖片存儲在 SQLite 數(shù)據(jù)庫中.如何在數(shù)據(jù)庫中存儲位圖?我正在將位圖轉(zhuǎn)換為字符串并將其保存在數(shù)據(jù)庫中.從數(shù)據(jù)庫中檢索它時,我無法將該字符串分配給 ImageView,因?yàn)樗且粋€字符串.

                  In my application I am uploading an image from gallery and I want to store this image in the SQLite database. How do I store a bitmap in the database? I am converting bitmap to a string and saving it in the database. While retrieving it from the database, I am not able to assign that string to ImageView since it is a string.

                  Imageupload12 .java:

                  Imageupload12 .java:

                       public class Imageupload12 extends Activity {
                        Button buttonLoadImage;
                        ImageView targetImage;
                        int i = 0;
                        Database database = new Database(this);
                        String i1;
                        String img;
                        @Override
                        public void onCreate(Bundle savedInstanceState) {
                         super.onCreate(savedInstanceState);
                         setContentView(R.layout.main5);
                         buttonLoadImage = (Button) findViewById(R.id.loadimage);
                         targetImage = (ImageView) findViewById(R.id.targetimage);
                      
                      
                         Bundle b = getIntent().getExtras();
                         if (b != null) {
                          img = b.getString("image");
                          targetImage2.setImageURI("image");
                          //i am getting error as i cant assign string to imageview.
                      
                         }
                      
                         buttonLoadImage.setOnClickListener(new Button.OnClickListener() {
                      
                          public void onClick(View arg0) {
                           // TODO Auto-generated method stub
                           Intent intent = new Intent(Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                           Log.i("photo", "" + intent);
                           startActivityForResult(intent, i);
                           i = i + 1;
                          }
                         });
                      
                        }
                      
                        @Override
                        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                      
                         // TODO Auto-generated method stub
                         super.onActivityResult(requestCode, resultCode, data);
                         switch (requestCode) {
                      
                          case 0:
                           if (resultCode == RESULT_OK) {
                            Uri targetUri = data.getData();
                            //             textTargetUri.setText(targetUri.toString());
                            Bitmap bitmap;
                            try {
                             bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
                             targetImage.setImageBitmap(bitmap);
                      
                             i1 = bitmap.toString();
                             Log.i("firstimage........", "" + i1);
                             targetImage.setVisibility(0);
                      
                             SQLiteDatabase db = database.getWritableDatabase();
                             db.execSQL("INSERT INTO UPLOAD VALUES('" + i1 + "');");
                      
                            } catch (FileNotFoundException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                            }
                           }
                           break;
                      
                      
                      
                         }
                      
                        }
                       }
                  
                  

                  Image.class:

                  Image.class:

                      public class Image extends Activity {
                       Database database = new Database(this);
                       static EfficientAdapter adapter, adapter1;
                       static ListView lv1;
                      
                       static SQLiteDatabase db;
                       static EfficientAdapter adp;
                       static Cursor c1;
                      
                       static Vector < String > IMAGE = new Vector < String > ();
                      
                       @Override
                       public void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        setContentView(R.layout.main);
                      
                        db = database.getReadableDatabase();
                        c1 = db.rawQuery("select * from UPLOAD;", null);
                      
                        if (c1.moveToFirst()) {
                      
                         do {
                          IMAGE.add(c1.getString(0).toString());
                      
                         } while (c1.moveToNext());
                      
                         c1.close();
                        }
                      
                        lv1 = (ListView) findViewById(R.id.List);
                      
                        adapter = new EfficientAdapter(this);
                      
                      
                        lv1.setAdapter(adapter);
                      
                        ImageView add = (ImageView) findViewById(R.id.imv1a);
                      
                      
                      
                        add.setOnClickListener(new OnClickListener() {
                      
                         @Override
                         public void onClick(View v) {
                          // TODO Auto-generated method stub
                          IMAGE.clear();
                      
                          Intent i = new Intent(Image.this, Imageupload12.class);
                          startActivity(i);
                      
                      
                         }
                        });
                      
                      
                       }
                      
                      
                      
                       private static class EfficientAdapter extends BaseAdapter {
                      
                      
                        //        protected  final Context Context = null;
                        protected LayoutInflater mLayoutInflater;
                        AlertDialog.Builder aBuilder;
                        public EfficientAdapter(Context context) {
                         // TODO Auto-generated constructor stub
                         mLayoutInflater = LayoutInflater.from(context);
                        }
                      
                        @Override
                        public int getCount() {
                         // TODO Auto-generated method stub
                      
                         return IMAGE.size();
                        }
                      
                        @Override
                        public Object getItem(int position) {
                         // TODO Auto-generated method stub
                         return position;
                        }
                      
                        @Override
                        public long getItemId(int position) {
                         // TODO Auto-generated method stub
                         return position;
                        }
                      
                        @Override
                        public View getView(final int position, View convertView, ViewGroup parent) {
                         // TODO Auto-generated method stub
                      
                         final ViewHolder mVHolder;
                         if (convertView == null) {
                          convertView = mLayoutInflater.inflate(R.layout.pjtlistdetails, parent, false);
                      
                          mVHolder = new ViewHolder();
                      
                          mVHolder.t1 = (TextView) convertView.findViewById(R.id.pjtdetails);
                          mVHolder.time = (TextView) convertView.findViewById(R.id.name);
                      
                      
                          mVHolder.imv = (ImageButton) convertView.findViewById(R.id.editic);
                          mVHolder.imvd = (ImageView) convertView.findViewById(R.id.delete);
                          mVHolder.imvf = (ImageView) convertView.findViewById(R.id.fwd);
                      
                      
                      
                      
                      
                          mVHolder.imv.setOnClickListener(new View.OnClickListener() {
                           @Override
                           public void onClick(View v) {
                      
                      
                      
                            String img = IMAGE.elementAt(position);
                            Log.i("image...", "" + img);
                      
                            Context ctx = v.getContext();
                            Intent myIntent = new Intent();
                            ctx = v.getContext();
                            myIntent.setClass(ctx, Imageupload12.class);
                            myIntent.putExtra("image", img);
                      
                            ctx.startActivity(myIntent);
                      
                            IMAGE.clear();
                      
                           }
                          });
                          static class ViewHolder {
                      
                           ImageButton imv;
                           ImageView imvd, imvf;
                          }
                         }
                        }
                       }
                      }
                  

                  推薦答案

                  你必須使用blob"來存儲圖像.

                  You have to use "blob" to store image.

                  例如:將圖像存儲到數(shù)據(jù)庫中:

                  ex: to store a image in to db:

                  public void insertImg(int id , Bitmap img ) {   
                  
                  
                      byte[] data = getBitmapAsByteArray(img); // this is a function
                  
                      insertStatement_logo.bindLong(1, id);       
                      insertStatement_logo.bindBlob(2, data);
                  
                      insertStatement_logo.executeInsert();
                      insertStatement_logo.clearBindings() ;
                  
                  }
                  
                   public static byte[] getBitmapAsByteArray(Bitmap bitmap) {
                      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                      bitmap.compress(CompressFormat.PNG, 0, outputStream);       
                      return outputStream.toByteArray();
                  }
                  

                  從數(shù)據(jù)庫中檢索圖像:

                  public Bitmap getImage(int i){
                  
                      String qu = "select img  from table where feedid=" + i ;
                      Cursor cur = db.rawQuery(qu, null);
                  
                      if (cur.moveToFirst()){
                          byte[] imgByte = cur.getBlob(0);
                          cur.close();
                          return BitmapFactory.decodeByteArray(imgByte, 0, imgByte.length);
                      }
                      if (cur != null && !cur.isClosed()) {
                          cur.close();
                      }       
                  
                      return null;
                  } 
                  

                  這篇關(guān)于如何將圖像存儲在 SQLite 數(shù)據(jù)庫中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                  <small id='C9Y85'></small><noframes id='C9Y85'>

                    • <bdo id='C9Y85'></bdo><ul id='C9Y85'></ul>
                      <tfoot id='C9Y85'></tfoot>

                              <tbody id='C9Y85'></tbody>

                            <i id='C9Y85'><tr id='C9Y85'><dt id='C9Y85'><q id='C9Y85'><span id='C9Y85'><b id='C9Y85'><form id='C9Y85'><ins id='C9Y85'></ins><ul id='C9Y85'></ul><sub id='C9Y85'></sub></form><legend id='C9Y85'></legend><bdo id='C9Y85'><pre id='C9Y85'><center id='C9Y85'></center></pre></bdo></b><th id='C9Y85'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='C9Y85'><tfoot id='C9Y85'></tfoot><dl id='C9Y85'><fieldset id='C9Y85'></fieldset></dl></div>
                            <legend id='C9Y85'><style id='C9Y85'><dir id='C9Y85'><q id='C9Y85'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 国产精品综合一区二区 | 国产精品久久久久久久久久久久久 | av一区二区三区四区 | 欧美综合国产精品久久丁香 | 99久久精品免费看国产高清 | 91精品国产日韩91久久久久久 | 91美女在线 | 中文字幕观看 | 久久久久成人精品 | 日韩一区二区三区在线观看视频 | 麻豆av网| 欧美成人性生活 | 美女视频黄的免费 | 久久久久久久久久久国产 | 亚洲视频一区在线观看 | 91视频网址 | 播放一级毛片 | 欧美中文字幕在线观看 | av天天干| 黄色片在线网站 | 国产成人综合在线 | 午夜精品久久久久久久星辰影院 | 成人福利网 | 亚洲性人人天天夜夜摸 | 国产女人与拘做视频免费 | 久久久久国产精品 | 国产成人免费视频 | 国产成人精品一区二区在线 | 天天想天天干 | 伊色综合久久之综合久久 | 成人免费观看网站 | 黄色网页在线观看 | 久国产 | 黄色大全免费看 | 日本欧美在线观看视频 | 中文字幕视频在线看 | 天天爽夜夜爽精品视频婷婷 | 精产国产伦理一二三区 | 免费久久视频 | 97精品一区二区 | 日韩av在线播 |