Deploy example files - Android Studio

Being new to Java, Android OS and Android Studio, I am a bit overwhelmed by all the information and hope I am asking the right questions on the right forum. I am developing an application where the user creates and edits files of a specific format. I want to include example files in my deployment so that the user can play with them right away. Now my questions are:
How do I include those files with Android Studio?
How do I define/create a directory for these files?
What would be standard locations for this directory which allow the user to access the files with a file manager?

frank-floripa said:
Being new to Java, Android OS and Android Studio, I am a bit overwhelmed by all the information and hope I am asking the right questions on the right forum. I am developing an application where the user creates and edits files of a specific format. I want to include example files in my deployment so that the user can play with them right away. Now my questions are:
How do I include those files with Android Studio?
How do I define/create a directory for these files?
What would be standard locations for this directory which allow the user to access the files with a file manager?
Click to expand...
Click to collapse
I've not yet made the transition to Android Studio, but in Eclipse there's a folder called /assets in the project structure. That folder gets built into the root of the APK. You can then access files in the /assets folder with the AssetManager.
Android puts tight controls on your access to devices resources. Each application has a default location for files that it can manage. You can retrieve the default working directory through the app Context. Check out Context.getFilesDir(). The application has the necessary privileges to read and write files to that location.

The crucial thing about internet search is keywords. The one I didn't know is "assets". Together with "android studio" I found a wealth of valuable links. Thanks for the help!

Related

creating personalized roms

my question is this, say for example I have my phone setup just as I like with the theme of my choosing, htc music app instead of the stock android app in the cyanogen mod. i would like to be able to create a rom from this setup that I could then just load on my phone as oppsed to loading a cm mod, then installing music player, then installing the theme. before the flaming begins, i tried the search to no avail. i am aware of how to sign the zip and all of that. just a point in the right direction would be MUCH appreciated.
Its something I would like to be able to do as well. According to Haykuros twitter hes going to be making a video about android rom cooking soon so that should help
jholt0130 said:
my question is this, say for example I have my phone setup just as I like with the theme of my choosing, htc music app instead of the stock android app in the cyanogen mod. i would like to be able to create a rom from this setup that I could then just load on my phone as oppsed to loading a cm mod, then installing music player, then installing the theme. before the flaming begins, i tried the search to no avail. i am aware of how to sign the zip and all of that. just a point in the right direction would be MUCH appreciated.
Click to expand...
Click to collapse
This should've gone in the Q&A section. Will probably get locked soon.
But in response to your question, I guess you could grab the CM rom, then grab the theme you use and overwrite the files in the rom, and then overwrite the music app with the HTC music. Resign and you got your update.zip customized how you want it.
xidominicanoix said:
This should've gone in the Q&A section. Will probably get locked soon.
But in response to your question, I guess you could grab the CM rom, then grab the theme you use and overwrite the files in the rom, and then overwrite the music app with the HTC music. Resign and you got your update.zip customized how you want it.
Click to expand...
Click to collapse
Thanks for the help and my apologies for the wrong section
how do you resign it?
joey3002 said:
how do you resign it?
Click to expand...
Click to collapse
by searching.
Stericson said:
Automatic version!
Do not use this to sign APK files in Vista or windows 7! It will cause your theme to loop phones when placed on a device. Only use this to sign update files if your using those O/S's
Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
An Example of this is c:\users\Nikki and Stephen\sdk\tools
Try to put the SDK and the contents of the zip in a dir where the names are all together and not like the one above.
I have made a batch file that will automate the entire process of setting up to use the signing tool made by JF. This batch file will set the CLASSPATH, set the PATH, install the registries, and will even allow you to sign files manually if you wish. I plan on building onto this batch file to include other things. However, for the moment, it will only include what you see here.
In order to use this you should have downloaded the sdk already. Simply extract all of the files into the tools dir of your sdk, and run autosign.bat follow the instructions and go through the options one by one, starting with 1 working through 4. You can however, put the contents of this zip anywhere on your computer and it will work. It is just better to put them into the tools dir of your SDK. Especially for the consideration of future versions.
Autosign .zip: http://www.fightforthepits.com/Androidstuff/signing.zip
Want to set up the signing tool manually?
Here is the link for the signing tool: Http://www.FightForthePits.com/testsign(2).zip
Before using this you need to know how to set this up:
Now you will need to add the tools dir of your sdk to the environment variable CLASSPATH.
FOR XP:
Right click on My Computer click properties, then choose the tab that says advanced.
Click the button that says environmental variables.
Go to system variables find the one that says CLASSPATH
double click it
go to the end of variable value.
There should be a semicolon ; at the end, type in the path to the testsign.jar located in the tools directory of your SDK
for example the path to my testsign.jar was c:\sdk\android-sdk-windows-1.0_r1\tools\testsign.jar
If CLASSPATH is not in your system variables then create it.
Secondly, Find the system variable called PATH and add to the end of it, the full path to your sdk directory.
For example, mine was c:\sdk\android-sdk-windows-1.0_r2\tools
FOR VISTA:
Open a cmd prompt.
Replace THEEXACTPATHTO-TESTSIGN with the path to the dir that holds the file testsign.jar.
Type:
echo %CLASSPATH%
If it is returns %CLASSPATH%
Type the following:
set CLASSPATH=THEXACTPATHTO-TESTSIGN\testsign.jar
If it comes back with something else then
Type the following:
set CLASSPATH=%CLASSPATH%;.;THEXACTPATHTO-TESTSIGN\testsign.jar
For Example, when I type this it looks like:
set CLASSPATH=%CLASSPATH%;.;c:\Android\SDK\tools\tests ign.jar
To set the PATH
Replace THEEXACTPATHTO-SDK with the path to the tools dir of your SDK.
Now type:
set PATH=%PATH%;.;THEXACTPATHTO-SDK\tools
For example, when I type this out it looks like this:
path-%PATH%;.;c:\Android\SDK\tools
Now through doing this you have done two things, first off you have made the resigning process extremely easy, secondly you will not have to cd to the tools dir of the sdk to use adb or any other tool in the sdk.
Signing the Files:
Now right click the reg file that you extracted and choose to install it, or merge.
Now, right click an apk, do you see an option that says ResignApk? That's how you will resign your .apks and .zips.
When you choose it a cmd window should open for a few seconds and then close. the file you signed will be overwritten with the new resigned file.
If you find the right click menu not working for some reason you can type the following in cmd to sign your files: java testsign whateverfiletosign
Click to expand...
Click to collapse
.apk's not showing up after flash in resigned .zip
Ok, so I've created a ROM to my liking. All the .apk's I normally use and got rid of the ones I don't. My problem is after I customized the ROM and flashed it none of the .apk's I added showed up. The only ones that showed up were the paid apps. I never opened the .apk's and made changes. I assume I don't need to change them to .zip resign and back to apk. Do I? I am using Windows 7 though and am able to resign no problem. Thanks to anyone who replies.

Help creating virtual sdcard for android emulator

Hi, I'm fairly new at developing android. Im having the hardest time making a virtual sdcard. can someone please give a some tips or a walkthrough. i've read all the how to's n googles dev forum.
ive gotten to the point where im in cmd.exe on windows
i opened the mksdcard.exe
the when i go to type in mksdcard 64M sdcard.iso
it says its not recogized as an internal or external command, operable program or batch file.
CAN ANYONE PLZ tell me whats going wrong. im so anxious to start deving for android!!
It sounds like the directory containing the Android command line tools isn't in your path, so the mksdcard program isn't being found. You'll need to edit your PATH environment variable and add the "tools" directory location to it. The "tools" directory is in the Android SDK directory on your computer, at the same level as the "platforms", "docs", "add-ons", and other such directories.
More details can be found on this under the "Download and Install the SDK" section of the Android developers website at http://developer.android.com/sdk/installing.html

[Q] Where does file created by fopen() resides ?

In Windows Phone 8 Runtime component (C++/CX) we can use fopen or CreateFile2 to create/open a file. For example
Code:
fopen("hello.txt", "w");
You see, I don't explicitly specify any path. And I can't figure out where this hello.txt resides? It can't be in Installed Location, and it isn't in Local Folder. Where is it?
Well, you could try the following:
_fileno() to get the integer file descriptor from the FILE*
_get_osfhandle() to get the Win32 HANDLE from the fd
GetFileInformationByHandleEx() to get the file name from the HANDLE.
I *think* those are even all supported on WP8, though I haven't checked except for the last one.
APIs like GetFullPathName() would make it easy, but may not be supported. CreateFile2 would let you skip the first two APIs in that list, if it works.
I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)
Whaaaaaat?!? That's... um. Serious. I'll look into it.
onmyway133 said:
I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)
Click to expand...
Click to collapse
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...
The install location is read/write to the app.
What
the
hell?
I can send test code if anybody wants, but it's easy enough to check yourself. You don't even need native code to do it, the .NET APIs work well enough.
I am somewhat confused.
mcosmin222 said:
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...
Click to expand...
Click to collapse
You can create a simple project to test this. In the C++ WP Runtime Component project, just use fopen or CreateFile2
Then use Hyper-V manager and Disk Management to easily inspect the WP .vhd file (I'm using Emulator)
You can use some things like IsoStoreSpy to see that the newly created file does not reside in the Local Folder (in WP8, they rename Isolated Storage to Local Folder)
I wrote a small app to test it; I can share the source if you want. It's really simple. I used the native APIs to create the file and write to it, then used the managed APIs to confirm it was there and read it, then used the native APIs to delete it, and the managed ones to confirm it was gone. Very simple. I then used the managed APIs to create the file myself (await Package.Current.InstalledLocation.CreateFileAsync("hello.txt")) and it worked.
Have you tried to create a xap file in the Install folder and reboot?
My 8X is freezing after creating a xap...
@spikedviper: No, I haven't tried anything like that. I don't seem to have write access from my app to the folder where pre-installed / OEM XAPs reside.
I did try editing the manifest; I was able to edit it with no problems but changing the capabilities didn't *do* anything, so I'm pretty sure it's still only parsed at install time.
hm...so what is the default path if no path specified?
looks like it stores it here: ms-appdata:///Local/ anyway check out "Data for Windows Phone" at msdn

Cntrl + click not working in Android studio

I am new to Android Studio.I like the IDE very much,it has got some nice set of features and has a rich look and feel, however I have some issues with the IDE. I recently created a Cordova application in android studio.I created an HTML file called index.html under assests/www folder.I included my jquery-1.11.3.min.js inside index.html file.I have the habit of checking whether the file jquery-1.11.3.min.js has been correctly included inside HTML file.In eclipse I use cntrl +click to check whether the js file path given is right.But when I use the same thing in Android studio,even if the path is right,it is showing like 'Cannot find declaration to go to'.Please help me on this.

Stop android studio creating a folder in home directory

I was wondering if it is possible to stop android studio creating the folder .AndroidStudio1.4 every time I run it. A way to change the location is also OK.
I asked this question on superuser and mentioned there I already succeeded in changing the locations of the subfolders. Now I just get an empty folder in my home directory.

Categories

Resources