Where to put keystore file in Android? - android

I am currently working on a project that involves ssl communication. So, I want to copy my bks file to the device' s internal memory and access it afterwards. I am using a specific library for communication and I have to provide the bks file' s full path as a parameter to this library. Where should I put this bks file? Into the raw or assets folder or somewhere else? From which uri can I access this file? (In windows I am giving it C:\keys\blah.bks, so I have to give a similar uri like /data/data/com.example.exampleapplication/my_app/blah.bks or something like this.) How is this achieved in Android system?
Thanks in advance

Store it in the assets folder of your app.
but consider encrypting it and letting your program decrypt it, since files in the assets folder are user accessible

Related

Download Audio file like Gaana Android app

I have created an Android Application, in that I am playing and downloading audio file from server. So when user download audio file from server he/she can't show that file in File Manager or any other media player like Gaana app.
How to make it possible?
Thanks,
Sagar.
You can save the files in Internal Storage Area. These files would be private to your app only.
Using getFilesDir() on any context provides absolute path to the filesystem directory where your internal files are saved. There in you can create directory. For more information refer here
You can use few approaches:
Download files into the private application's directory. No other apps will have access to those files. Pros of this approach is that is is the easiest way. Cons is that the inner storage might be limited in the device.
Download files saving them with incorrect file extensions. Pros: easy to implement, can save anywhere. Cons: files can be accessed, copied and renamed by any other app.
The same way as 2nd approach, but add some encryption to the files, so nobody except you can use them. This approach might require on-the-fly decryption.

How can i insert a .bin created on desktop file into apk

I have code for creating an internal file, there is random algorithem that create the data stored in it and i want any app to have the same file with the same binary data in it.
so i need to make the file on my desktop and add it to internal files some how.
my question is what do you think is the best way to do it.
i thought to locate it in my project, read it, and write it to internal files.
the problem is, i dont know where to locate my file in android studio so that it will be included in the external files and then where to read it from.
thanks. =]
hope i made myself clear.
Put it in src/main/assets/.
You can then access your file with AssetManager and do whatever you want with it.
From the Android Developers website:
main/assets/
This is empty. You can use it to store raw asset files. Files that you
save here are compiled into an .apk file as-is, and the original
filename is preserved. You can navigate this directory in the same way
as a typical file system using URIs and read files as a stream of
bytes using the AssetManager. For example, this is a good location for
textures and game data.
You need to move that into the assets folder. From there you can refer to the file.

How to put a *.cfg file to the same directory as the *.apk file?

I am really new to android devices, we have got an app that needs to read a *.cfg file from the same place as the apk. So the question is:
1) When i attach my mobile-phone to the computer, can i put it from the explorer? If yes, how?
2) Is there a mechanism in Android, that looks for some kind of include directories
when opening a Program?
It would be great if you could give me a hint.
You'd want to drop the *.cfg files into the assets/ folder. Then the app will have access to those raw *.cfg files during runtime.
From Managing Projects
assets/
This is empty. You can use it to store raw asset files. Files that you
save here are compiled into an .apk file as-is, and the original
filename is preserved. You can navigate this directory in the same way
as a typical file system using URIs and read files as a stream of
bytes using the AssetManager. For example, this is a good location for
textures and game data.

libgdx android Local file

I'm trying to save the Setting in a Local .txt file. But I don't know where i have to put the txt file, that the desktop as well as the android application can find it.
I hope you can help me with this little Problem.
Thanks
For settings, I'd probably just use the LibGDX Preferences interface which works cross-platform. On Android, it uses SharedPreferences, on Desktop it uses an XML file stored in the user's home directory.
The Local file type in LibGDX provides access to the internal app-specific storage (/data/data/com.company.package/files) on Android, and stores the file alongside the jar for Desktop. There is no way to provide a Local file up front at compile time, aside from packing it as an Internal file and extracting it to a Local (or otherwise generating the file with code at run-time).
settings are usually stored using android.content.SharedPreferences:
http://developer.android.com/reference/android/content/SharedPreferences.html
or you can write the txt file to the device, see this tutorial:
http://chrisrisner.com/31-Days-of-Android--Day-23%E2%80%93Writing-and-Reading-Files

Android Encrypting and Decrypting a resource file in a App

In Android how to decrypt a text file present in resource folder and use the data in it. So that i can maintain a encrypted file inside the resource folder in that apk. Help me to get this.
Take a look at the javax.crypto.Cipher packages.
Example here:
Android File Cryptography

Categories

Resources