android - How to get file name and real path of Google drive document? -
i using following code file name , path of files in file manager. not return path google drive files. idea how obtain actual path?
my code -
public string getfilepath() { if (uri.getscheme().equalsignorecase("file")) { return uri.getlastpathsegment(); } cursorloader.seturi(uri); cursorloader.setprojection(projections); cursor cursor = cursorloader.loadinbackground(); int column_index = cursor.getcolumnindexorthrow(mediastore.files.filecolumns.data); cursor.movetofirst(); string realpath = cursor.getstring(column_index); cursor.close(); if (realpath == null || realpath.isempty()) { return null; } return null; }
you have use uri. through uri can getcontentresolver.query(theurithatyouhave, null, null, null, null)
. have cursor, can check column names etc.
for google drive there column name _display_name
. give file name.
now want access file? can open inputstream
uri via getcontentresolver().openinputstream(theurithatyouhave)
.
Comments
Post a Comment