I Can't view my generated EXCEL DOCS from my computer - java

I can output the files and store then in a location on the device just fine with
File dir = new File(Environment.getExternalStorageDirectory(), "Army PRT Manager");
dir.mkdir();
File file = new File(dir, fileName);
I can view the files on /storage/emulated/0/Army PRT Manager
However, when I browse to that folder via my laptop to copy the created documents I can't find the folder.
All folder options have been changed to View hidden folders/files.
Is this a problem with many devices and can anyone suggest how I can save in a way that I would be able to see the documents more easily.
Maybe save them to the download folder?
Thanks.
Also when I open my device on my computer it only shows a Internal storage folder to open. I just want to be able to write to a directory that is easy to get to from a computer or file manager on the device. =(

What shows up via the MTP connection to your laptop is what MediaStore knows about. Use MediaScannerConnection and scanFile() to tell MediaStore about your file, after you have completely written it to disk.
Even with this, depending upon your laptop's OS, you may need to do some sort of "refresh" in a file manager to get it to pick up the new file, or possibly even unplug and re-plug in the device.

Use this code after dir.mkdir()
MediaScannerConnection.scanFile(this, new String[]{dir.toString()}, null, null);

Related

How to read txt file from Google Drive?

I'm trying to make launcher for my game. I want it to display update log. How I want it to work:
Replace log.txt file on Google Drive and new log will be displayed in launcher.
I have no idea how to make this. Also I have to make auto-updater.
It will work similiar to update log - upload .jar file and res folder on drive. When game launched it will check for updates and if new update available it will download it.
Like I said, I have no idea how to do this.
I advise you to use GitHub to upload your files. Then you can use the URL provided by GitHub to open a urlStream in your project and read that file like a .txt.
Google drive is a file explorer only. It will allow you to upload and download files, it does not have the power to display or edit them. Unless you want to display them in the Google drive web application in which case there should be a webContentLink available in the response data for the file.get method, however the file will need to be either public or the user must have access to it in order to be able to see it.
To display the file you will need to download it and display it locally. To edit it you will need to download the file and edit it then upload it again.
Tbh i think what you are asking is out of scope for this api.

Make videos playable just in my app

I'm making an app which contents should be downloaded from a server. After downloading videos, I want to prevent them from publishing or sharing. I searched about this and find out that putting a dot (.) before the name of the video will hide it from file manager and gallery. But if the user uses a professional file manager would see the videos!
I want a solution to make videos unplayable via other apps.
As far as I Know, you could put your files in your internal directory which is private and only your app can access it.
but still, devices with root access can view and edit your files.
you can get private file location via context.getFilesDir()
You can use cache directory instead of External storage
Ex:
File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR);
each app has own cached directory and can accessible only for that app (unless root)
That one simple way to hide media from other apps
more

Prevent Google Photos to ask for backing up app folders

I am making a chat app that stores sent images in it's private folder on external storage. After saving an image the Google Photos app notices that and asks if the user wants to backup that folder.
Is there a way to prevent that?
'.nomedia' file does not help.
Kindof, Google backup reads imgs and video types.
There are 3 workarounds that I know,
Make the Folder hidden.
Add "." before the folder name. (when u create the folder)
Have a lot of folder hierarchy.
Example: /0/AppName/sentimgs/ <- Can be read by google backup
/0/AppName/bla/bla/bla/sentimgs/ <- Cant be read.
Save the img without an extension. And make ur app add it when they want to view it.
The Shank's first solution worked for me.
However, I noticed that I created .nomedia file wrong, so after fixing it the backup problem has been also solved.

Android access file system nexus 7

Background
I am developing an android application that will only be used on Nexus 7 tablets (my team is also providing and has access to the hardware).
Problem
The app needs to be flexible to allow content to be added (by non-tech savvy users) to the app and accessed without an internet connection.
Our Idea
Android devices have a file system. We want to design a file system layout such that the people adding content to the application can drag and drop into the correct folder.
e.g.
AppName
Images
Videos
If the user adds a video to the videos folder of the device under our app, it will show up in the app.
We understand that this could easily go wrong (accidentally delete a folder, etc.) but this is out best attempt to solve this without having to update the app ourselves whenever new content comes up (and remember, no internet connection!).
The Question
Is it possible to access the android file system contents and insert them into an app as described in the "Our Idea" section? If so, how?
Yes. This is possible if you don't bother about content security. You can copy the content to any of the file system path in sdcard and your app can look for the folder and read the files .
Example , you can create a folder in sdcard as
sdcard/appname/media/
and create a layout to access the files in the device, and when user selects the files provide option to copy it to your sdcard/appname path.
Check this link
http://developer.android.com/training/basics/data-storage/files.html
Note : the sdcard path can be accessed if you connect to any external system ( PC).

Opening cached file in android

I'd like to open a file that I written copied to my cacheDir (e.g audio file, or image) with an intent, but it seems like other apps don't have the permission to this directory. It's quite reasonable (my logic tells me that only root and the app have the access to this folder), but is there any workaround for this issue?
Well, that's quite obvious my friend, use activity.getExternalCacheDir() to obtain a cache dir on your SD card. Just don't forget to set the permissions.

Categories