我的Google雲端硬盤中有一個Spreadsheet文件,我想從Android應用程序進行同步。成功同步後,我在我的應用程序中有一些搜索條件,我希望從我同步的文件中獲得基於此條件的結果。我這是第一次這樣做,並沒有得到好的資源開始。如何在Android應用中同步Google電子表格並從中讀取行
1)如何在Android應用程序中同步Google Drive文件?
2)如何從我已同步的電子表格中檢索特定的數據?
注意 - 我也搞不清楚谷歌文檔API &谷歌硬碟SDK之間。
在我的應用程序中使用什麼?
我只有一個文件要每次同步,而不是所有的文件。並且該文件對所有人都使用私鑰開放。
我已經實現了一些代碼,但它不工作。以下是我想在我的android應用程序中同步的電子表格公開網址。
我從here以下步驟。
try {
String USERNAME = "xxxxx";
String PASSWORD = "xxxxx";
SpreadsheetService service =
new SpreadsheetService("Testing");
service.setUserCredentials(USERNAME, PASSWORD);
// TODO: Authorize the service object for a specific user (see other sections)
// Define the URL to request. This should never change.
URL SPREADSHEET_FEED_URL = new URL(
"https://spreadsheets.google.com/feeds/spreadsheets/private/full");
// Make a request to the API and get all spreadsheets.
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL,
SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
if (spreadsheets.size() == 0) {
// TODO: There were no spreadsheets, act accordingly.
}
// TODO: Choose a spreadsheet more intelligently based on your
// app's needs.
SpreadsheetEntry spreadsheet = spreadsheets.get(0);
System.out.println(spreadsheet.getTitle().getPlainText());
// Make a request to the API to fetch information about all
// worksheets in the spreadsheet.
List<WorksheetEntry> worksheets = spreadsheet.getWorksheets();
// Iterate through each worksheet in the spreadsheet.
for (WorksheetEntry worksheet : worksheets) {
// Get the worksheet's title, row count, and column count.
String title = worksheet.getTitle().getPlainText();
int rowCount = worksheet.getRowCount();
int colCount = worksheet.getColCount();
// Print the fetched information to the screen for this worksheet.
System.out.println("\t" + title + "- rows:" + rowCount + " cols: " + colCount);
}
} catch (Exception e) {
e.printStackTrace();
}
請你們幫助我,如果任何人有任何idea..I我期待您的建議... – Scorpion
你如何管理同步谷歌雲端硬盤文件的Android應用程序? – Ajay