Android 11: Create *package name* folder in Android/data by default? - android

Im trying to create a specific folder in /Android/data/package name/ from C++. Im using mkdirs for that. Not a big surprise it crashes the whole app because it doesnt have an access to Android/data (that means app cannot create it's own app folder). If i create package name folder by myself, then i can easily create folders and/or files inside it.
How can i do this? Am i missing something?
FIXED: Thanks #blackapps for a hint with getExternalFilesDir! You're lifesaver!

Related

How create folder (and file) within the installation of app in Android?

I want to create a folder with pictures just in installation.
I searched a lot for this but I didn't found nothing but a lots of apps do that. I speciffically mean the Android folder in /storage/emulated/0/ or /sdcard/.
That is not possible, sorry. You are welcome to create directories and files when your app is run by the user. There is no option for doing so just because your app is installed.
you can create the folder after the app is installed.. However you can design your code such that it creates folder while loading the Application for first time.

Create folder inside android folder of android device

We all know there is always a folder in android named Android which always contains data of app.
I saw many app folder inside it which store their file there.
So my question is how can i create a folder inside android folder of an android device and store my application data inside of it?
Please suggest something
We all know there is always a folder in android named Android which always contains data of app
I am assuming that you are referring to the Android/ directory seen in what the Android SDK refers to as external storage.
how can i create a folder inside android folder of an android device and store my application data inside of it?
Use getExternalFilesDir(), getExternalCacheDir(), or getExternalMediaDir(), all methods available on implementations of Context, such as Activity and Service.
Also, if you want to be able to see the files that you create from your desktop OS, you will need to arrange to have the files indexed by the MediaStore.

Cordova/Phonegap - Where do I put a data file I want to read?

I've been driving myself crazy trying to find the answer to a seemingly easy question.
I am trying to create my first app using Cordova. I want to bundle a text file with my app that can be read when the app starts up.
Where do I put this file?
dataDirectory seems like a good place, but where is it? Documentation says /data/data/<app-id>/files but where are those data directories? Do I create them?
Update 1: Ok, I think I've figured out that dataDirectory should be pretty much just where the path says it should be, at the root of the file system. But the directory doesn't appear to be created automatically and I don't know how to package a file - a JSON file, for instance - and place it in that directory.
Essentially you do not need to create these directories. Those are created once your app is installed by the Android itself.
A typical way to get this done would be that you could first off add those files in your app's assets directory and then at runtime you can copy those file wherever you want.
There is a repository on Githup which provide a similar functionality.

Where is the SQLite datase file?

I've created an app using Android Studio and it has a database file handler. I've gone through a few post and everywhere they are saying go to data\data\ folder to get the app folder. But mine doesn't show any folder for my app. Do I have to manually set this file location to be created? How can I find my database.db file?
It should be automatically placed in data/data/databases in your app folder unless you specify otherwise. Are you sure it is created?
That is /data/data/package-name/databases/dbfilename
I have another suggestion. If you have enabled backup for your application, you might be able to use ADB BACKUP, like suggested here: http://blog.shvetsov.com/2012/09/backup-your-android-without-root-or.html
The database files are located in the following folders.
/data/data/packagename/databases/
You can access the .db file only on emulator, its not possible on actual device. In the android studio open the DDMS perspective, there on the left hand side you will find the storage structure, there in data/data/ you will get the file you are looking for

Data in XML: where to place it

I am trying to design a new Android application.
For that application I will have an XML file that will be located somewhere on the server. This file will be generated from the mySQL DB.
For now (developmental phase) I got a simple and small XML file that I need to put in the Android Eclipse project in order to read it and present the data on the phone.
I just tried to put this file in res/values, but compiler gives me an error: "Invalid start tag".
Looking through the stackoverflow and google I see a lot of different answers and google even give me an answer of how to parse xml file on Android. ;-)
So is there a "standard" place where such XML file goes in Android Eclipse project? Think about it as the data that is read from the DB.
Some answers are to place it in the res/xml folder. I just made a brand new Android project and I don't see such folder in it. Do I create one? Shouldn't it be done automatically?
Some says you need to put it the res/raw folder. Again it is not present in the Eclipse project. Do I make one? Shouldn't it be present already?
Please clarify.
Shouldn't it be present already?
It doesn't have to. There can be thousands of folders inside res/ folder. You don't want to have them all at first.
Do I make one?
Yes. Add folders when you need them.
Some answers are to place it in the res/xml folder.
Some says you need to put it the res/raw folder.
The difference between these folders is that files inside raw stay the same you put them and inside xml are parsed when APK is created and put there in a binary, optimized form, similar to what happens to layouts, AndroidManifest and other.

Categories

Resources