Hiding a folder in android not using "." extension - android

How can I hide a folder in android? I am downloading some data from the app which must be accessible only through my application. Currently, I am hiding folders by putting "." extension to the folder name and saving it in the app directory. But it will get visible when switching on "show hidden option" in file managers and enter the particular app data. Kindly suggest some methods by which we can hide data similar to what we see in amazon prime application and all.

Unless the user roots their device all internal files are accessible only to your app. Beyond that, there is no use case and no acceptable reason to hide files from the person who actually owns the device.

Hiding a folder in android not using “.” extension
you can use internal storage as an alternative to hide the folder, if the device is rooted don't allow the app to be installed, if the user roots the device after app install no matter what you do things will be accessible.
//Create internal dir;
File mydir = context.getDir("DIR_NAME", Context.MODE_PRIVATE);

Currently solved my issue by saving files to Internal Storage.
We can use either
File file = new File(context.getFilesDir(), filename);
or
File mydir = context.getDir("DIR_NAME", Context.MODE_PRIVATE);
for saving it in internal directory.
But if rooted device the issue will persist

Related

Create Non Readable Directory in Android

I want to create a directory in device internal storage, which should be hidden for all the user from other apps like file explorer or file manager. Should I use any encryption technique for this?
If the folder is on internal storage, it will already be hidden from file explorer and file manager apps, unless the user has a rooted phone. If he has a rooted phone, there is no way you can hide the folder from him.

Android - How to create a folder that can't be accessed by user?

I have created a file inside one folder in android and I have encrypted that file. When user clicks "READ" button in my app, the specified file will be decrypted in same folder. but I want the users not to access those files via USB or file manager. How to implement this concept?
Use this
context.getDir(null, Context.MODE_PRIVATE);
In place of
context.getExternalCacheDir()
This will solve your problem.

android hide folder to sd card and share the image inside the hidden folder

i want to hide a folder created on my external storage the get the path of the hidden folder to share data found inside the hidden folder. how can i achieve this. what i have done since now.
Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File imagesFolder = new File(Environment.getExternalStorageDirectory(), "/mdata/");
imagesFolder.mkdirs();
the sharing
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/mdata/"+path));
You can hide the folder from most scans etc. by prefixing it with a .. This will make it a UNIX hidden folder.
However, users can still browse it with a file manager or on their computer, and apps can still access it if they want to.
If you want your data completely hidden from other apps, store it on a private server. Even the internal storage can be read with root, and the external storage can be read by any app with the permission to do so.
If you want to hide folder in Android or any Linux based system just add . as prefix to folder or file name.
However if you mount your SD card on Windows machine then these folders will be visible, with the . in front of the folder name, as a normal folder.

How to delete file from SDcard when uninstalling the application

I have application that record a sound, I want to delete this sound file when uninstalling this application. how is that possible ?
You should store the files in the internal storage. Thus, when the application is removed, so are the files.
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
There are 2 ways to saved the file so it can be deleted upon uninstall
on the SD-card:
in an app only file note that it is deleted automatically only on API 8 and above.
// find or create private file need to be in a Context object
File root_private_SD_Card_file = getExternalFilesDir(null);
File myOwnFile = getExternalFilesDir("MyOwnFile") //
String path = myOwnFile.getAbsolutePath()
this method also hides the image video and audio files from other applications
2.
by storing directly to the device's storage from within a context
openFileInput(fileName);
[android developer's link][1]
This method can be problematic because device storage can be limited or occupied.
If the minSdk of your application is 8 you can use
context.getExternalFilesDir(null)
as the doc stands:
Returns the absolute path to the directory on the external filesystem
(that is somewhere on Environment.getExternalStorageDirectory()) where
the application can place persistent files it owns. These files are
private to the applications, and not typically visible to the user as
media.
When you uninstall the application, the related directory would be deleted (tipically the root would be com.yourdomain.yourappname).
If you have a Samsung phone with Android ICS, that does not work (I think it is a bug)

How to create private folder in sdcard

My application is used for security purpose. so, from my application user captures photos that all photos are stored in a folder that folder should not access from any other application and should not give access when devices connect to computer system. If user wants to view these images he should access only from my application.
According to this guide, you can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.
For example:
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.
The only way, AFAIK is to encrypt the files that you store. There is no way to prevent users mount the sdcard to access every file stored in it.
according to this related question, you can only create protected files in internal storage (not on the SD)...
Create Folder that can not accessible by any other application
Try following solution:
How to store a file in Hidden mode
Although it is not exactly what you want and I doubt whether it is possible or not. The best option would be to make it hidden but that also works with constraint (works for linux and not for Windows, still other applications can access the folder)
How to hide the folder of sdcard in android
How to make a file hidden in android sd card?
Its not possible to give no access to that folder when device connected to pc.. Also its not possible on sdcard also,
But you can use different format for images that can be opened only from your application, or you can encrypt images.
Or if you want to hide images from showing them into gallery, you can put a blank file with name as ".nomedia" in your folder.
But its not possible cause if u read docs about WRITE_EXTERNEL_STORAGE permission you will understand what I am saying. :)

Categories

Resources