- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
How to create and save an image file in Download folder from your Android App? - Android 13 | API 33
In this video it shows the steps to create and save an image file in the download folder from your Android App. The App is developed in Android Studio for Android 13 - API 33 version.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details/ steps of this video are posted in the below link:
https://programmerworld.co/android/how-to-create-and-save-an-image-file-in-download-folder-from-your-android-app-android-13-api-33/
However, the main Java code is copied below also for reference:
package com.programmerworld.savefileindownloadfolder;
import static android.Manifest.permission.READ_MEDIA_IMAGES;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.view.View;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActivityCompat.requestPermissions(this,
new String[]{READ_MEDIA_IMAGES, WRITE_EXTERNAL_STORAGE},
PackageManager.PERMISSION_GRANTED);
}
public void buttonCreateImageFile(View view) throws IOException {
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
StorageVolume storageVolume = storageManager.getStorageVolumes().get(0); // internal Storage
File fileInputImage = new File(storageVolume.getDirectory().getPath() + "/Download/images.jpeg");
Bitmap bitmapInputImage = BitmapFactory.decodeFile(fileInputImage.getPath());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmapInputImage.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] bytesArray = byteArrayOutputStream.toByteArray();
File fileOutput = new File(storageVolume.getDirectory().getPath() + "/Download/output1.jpeg");
FileOutputStream fileOutputStream = new FileOutputStream(fileOutput);
fileOutputStream.write(bytesArray);
fileOutputStream.close();
}
}
--
Видео How to create and save an image file in Download folder from your Android App? - Android 13 | API 33 канала Programmer World
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details/ steps of this video are posted in the below link:
https://programmerworld.co/android/how-to-create-and-save-an-image-file-in-download-folder-from-your-android-app-android-13-api-33/
However, the main Java code is copied below also for reference:
package com.programmerworld.savefileindownloadfolder;
import static android.Manifest.permission.READ_MEDIA_IMAGES;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.view.View;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActivityCompat.requestPermissions(this,
new String[]{READ_MEDIA_IMAGES, WRITE_EXTERNAL_STORAGE},
PackageManager.PERMISSION_GRANTED);
}
public void buttonCreateImageFile(View view) throws IOException {
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
StorageVolume storageVolume = storageManager.getStorageVolumes().get(0); // internal Storage
File fileInputImage = new File(storageVolume.getDirectory().getPath() + "/Download/images.jpeg");
Bitmap bitmapInputImage = BitmapFactory.decodeFile(fileInputImage.getPath());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmapInputImage.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] bytesArray = byteArrayOutputStream.toByteArray();
File fileOutput = new File(storageVolume.getDirectory().getPath() + "/Download/output1.jpeg");
FileOutputStream fileOutputStream = new FileOutputStream(fileOutput);
fileOutputStream.write(bytesArray);
fileOutputStream.close();
}
}
--
Видео How to create and save an image file in Download folder from your Android App? - Android 13 | API 33 канала Programmer World
Комментарии отсутствуют
Информация о видео
31 января 2023 г. 23:00:31
00:09:10
Другие видео канала





















