我正在设计 Android 应用程序,它将图像文件从 SD 卡中的特定文件夹上传到 Google 驱动器。但我得到
E/AndroidRuntime( 6808): FATAL EXCEPTION: main
E/AndroidRuntime( 6808): java.lang.OutOfMemoryError error while trying to upload the files.
代码片段:
File sdDir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File yourDir = new File(sdDir, "CameraAPIDemo");
for (File f : yourDir.listFiles()) {
if (f.isFile()){
String name = f.getName();
Log.i(TAG, "name =" + name);
String CompletePath=yourDir + "/" + name;
//Decode the file from the folder to bitmap
Bitmap bmp = BitmapFactory.decodeFile(CompletePath);
saveFileToDrive(sFolderId,bmp,name);
}
saveFileToDrive 包含将一个文件上传到谷歌驱动器的逻辑。如何进行?请帮我.....