i have an android app, which imports and exports zip files. When exporting, the app creates a zip file with the extension (lets say) .xyz123
Now,when I go to the explorer and click on the file (e.g) text.xyz13 , android offers multiple apps to open my file.
Question: HOW-TO manage, that the file will only be opened by my app ?
thx a lot :)
that the file will only be opened by my app ?
Don't have the file on external storage in the first place.
If the user can get to the file via some sort of "explorer", then the user gets to decide what to do with that file, just as they can on any other operating system.
Moreover, the typical role of "imports and exports" is to allow the user to do whatever they want with the file.
Related
I created a project which uses Fragments, and in one of them I want to add some clickable icons that will allow to download a file (one per icon).
I have the files stored on my computer.
I suppose that they have to be copied into my application.
How I can implement this in the code?
I hope that this picture can explain what I want to do.
will allow to download a file and they have to be copied into my application don't match: If the files are already on the device (once your app is installed), what is the sense of downloading those files again?
Therefore, either provide your files inside your app or use a file server and download them.
If you decide to provide the files in your app, this will increase the installation time.
But it would not require an internet connection to download the files again.
So, simply put your files in the raw or in the assets folder and that's all.
Then simply access your files from that folder.
If the folder isn't already found in your project, simply create it and drop your files in it.
Using PhoneGap 3.2 and the File API, I'm downloading a set of images to display in the app. I create a folder named "Appname" and put all the files there. On Android this folder is accessible through the file manager, and on some models the images show up in the users image gallery.
Is it possible to save files locally, but prevent them from showing up to the user outside of the app?
Technically, no. Especially if the client has root access.
You may try the followings to mitigate the problem:
a) Name your files to start with a DOT (.) so that it is recognized as hidden file. (Still, a file manager configured to show hidden files can show it).
b) Store the file instead on some databases in the /data/data/your.app.packages path, which is by default only accessible to your app. (Still a root user can see it).
c) A linux trick. Create a file, open it, hold the file descriptor but remove the file. In this way the file is removed from the directory structure so that it doesn't show up in the FS layer (and thus inaccessible). To make it permanent, use the file descriptor you hold to create a link (or dig into the /proc directory tree to make links with files under fd.
Since this trick works on linux, I guess it should work on Android. But it's probably overkill.
d) Other stopgaps include encryption, obfuscation, etc. But they don't exactly fall into the kind you are looking for.
I have a document file stored in my application's data folder, which is a kind of private folder to the application. It is a .doc file. I have doc viewer application installed in the device. Now, how can I open the file with the Action_view intent. As the viewer application can't access file stored in my application data folder, it is throwing an error saying file can't be accessed. I have no interest to copy the file to phone public folders like sdcard. Is there anyway to open that doc file. Any clue on embeded apk in android.
Thanks & regards,
Suman
You can't do this directly. Either copy the file temporarily to the SD card (external storage) or set permission temporarily to WORLD_READABLE. There are no embedded APKs in Android, but if the viewer is available as library you can include it in your app. Of course the problem with changing permissions temporarily is that you don't really get notified when the user has finished viewing it, etc.
The whole thing begs the question: why is it a private file if it needs to be viewed by third party applications? If it is meant for the user of the device, there is not much point in hiding it from them...
I have an android application I am developing in Java.
I need it to load a text file so it can read what is in the text file and get values from it.
However, everything I have read so far has been directing me to use resources and package it up with the application.
However this means if I want to change the text file, I have to reinstall the application, which is not what I want.
I need to end up with the .apk file and the .txt file in the same folder on my android phone so I can change the .txt file and the app reads in the text file in its directory.
Can anyone help?
No, you do not want to end up with the .apk and the .txt file in the same folder.
You want to end up with the .txt in some place that's always the same and that you know about.
You can deploy the initial .txt via the ressources (aka: package it and copy it to the sd for example) and later download a new version (or copy something to the device via usb).
Then inside your app check if the file exists and open it with standard Java. There's plenty of source around for that.
Why does android allow delete a file, although it is being used by another application?
For example: I have a mp3 file on sdcard, I use mp3 player to play it, and then I open a File Manager app and browse to that file; delete it successfully.
If on windows, a message will be displayed and we can't do that.
Why does the android operating system not?
I don't know the principle of file management on android os.
Does anyone have document about it? Help me please!
Going with the information from here (similar query to yours), linux file deletion only removes the pointers to the file until the last process using that file is complete. At this point the contents of the file are freed.
What this means is that the following should not work:
Play an MP3 file from the SDcard.
Open up file manager app and delete said MP3 file.
After MP3 file finishes, attempt to play it again.