How to implement SQLite database to store Bitmap Image and Text?

后端 未结 3 614
忘了有多久
忘了有多久 2021-01-28 00:11

hello all i am developing an android application which listen to incoming whatsapp notification and show it in listView using NotificationListenerService. i need he

3条回答
  •  别那么骄傲
    2021-01-28 00:37

    If your image is really small you can covert it in a String by means of android.util.Base64 encoding and put this string in SQLite database:

    public static String getPngAsString(Bitmap bitmap){
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
        byte[] bitmapBytes = bos.toByteArray();
        return Base64.encodeToString(bitmapBytes, Base64.NO_WRAP);
    }
    

提交回复
热议问题