Posts

Showing posts from June, 2017
convert Image to base64 string java android Code Is working Code Uri selectedImage = data.getData(); String[] filePathColumn = {MediaStore.Images.Media. DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null , null , null ); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[ 0 ]); String imgDecodableString = cursor.getString(columnIndex); cursor.close(); File imgFile = new File(imgDecodableString); Bitmap bm = BitmapFactory. decodeFile (imgFile.getAbsolutePath()); policeform = Base64. encodeToString (getBytesFromBitmap(bm), Base64. NO_WRAP ); String policeform1 = policeform ;
convert pdf to base64 string java Android Code is working code Uri uri = data.getData(); String uriString = uri.toString(); File myFile = new File(uriString); String path = myFile.getAbsolutePath(); String displayName = null ; if (uriString.startsWith( "content://" )) { Cursor cursor = null ; try { cursor = this .getContentResolver().query(uri, null , null , null , null ); if (cursor != null && cursor.moveToFirst()) { displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns. DISPLAY_NAME )); inputStream = getContentResolver().openInputStream(uri); //You can get an inputStream using any IO API byte [] bytes; byte [] buffer = new byte [ 8192 ]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { while ((bytesRead = inputStream .read(buffer)) != - 1 ) { output.write(buffe...