Google Drive API in Android Studio Tutorial (PART 2)
Why Stack Overflow recommends it
Stack Overflow users link it as a worked example when asking about or answering Google Drive upload and sign-in problems in Android apps.
Recommended by 1 people across 1 different months, 2021 to 2024.
What it is
A 10-minute tutorial from the channel Android with Haroon, part 2 of a series on using the Google Drive API in Android Studio. It combines Google Sign-In with the Drive API so a signed-in user can upload documents or PDFs to their Drive account.
What people said
Recommends Kristkun · 2021-03 · Stack Overflow · on “Saving a file in Google Drive from Android”
If you are looking for a reference on how to upload files using Drive API in Java, you can refer in this official document Upload file data [LINK] . Simple upload - upload the media only, without any metadata. Multipart upload - upload both the media and its metadata, in a single request Sample Java Code (Multipart Upload): File fileMetadata = new File(); fileMetadata.setName("photo.jpg"); java.io.File filePath = new java.io.File("files/photo.jpg"); FileContent mediaContent = new FileContent("image/jpeg", filePath); File file = driveService.files().create(fileMetadata, mediaContent) .setFields("id") .execute(); Note: Your FileContent() expects a file type in its first parameter, you can choo
Cites SepidehDev · 2023-04 · Stack Overflow · on “onActivityResult not called after click the button (using Google Drive API)”
I use the following link to use the Google Drive API to upload a file to Drive: [this video] When I call requestSignIn() in onCreate, it works correctly. But when I call it in setOnClickListener, it doesn't work! My code looks like this: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // When I call requestSignIn here it works correctly // requestSignIn(); } private void requestSignIn() { GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestScopes(new Scope(DriveScopes.DRIVE_FILE)) .build(); GoogleSignInClient client = GoogleSignIn.
Cites Ayşe Nur Aslan · 2024-03 · Stack Overflow · on “Can Google Drive act as a DB for Mobile App?”
Using the Google Drive API for your mobile app's database is not ideal: Not designed for databases. It can be slow and inefficient for frequent read/write access. Granting access to a user's entire Drive can pose a security risk. I recommend considering local storage, SQLite or cloud databases like Firebase Realtime Database or Cloud Firestore. If you still want to use it, the links below will help you. [LINK] [this video]