Save Data from internet in asset folder - android

I want to save data from internet in asset folder in Android. I used Eclipse IDE to develop the android application.
How i can achieve this ?
Thanks.

The assets directory is readonly. It's defined and initialized at compile time, you cannot add or edit its contents.
Source (note it doesn't mention anything about writing to files...only reading them.)
Use the SDCard for such operations.

slote is right . use internal file storage/SD Card or sqLite database to save image

Related

SQLite Database in external sdcar

i am newbie to android .
.
I have problem that how to get external storage directory.In my device it is storage/sdcard1 path.
but it is also not working.
How can I set external storage directory path to db ?
PLease help.
Any answer will be appreciated.
Before answering this question I want you know something about the android framework..
Android contains default sqlite handling options which saves database file in internal storage directory
It is good practice to use it..
But still if you want to save in custom directory follow these instructions
By default android partitions the internal storage into a partition called SD card
which can be accessed by calling frameworks Function
File Environment.getExternalStorageDirectory()
But on some devices there is an option have external memory card
If that is your case you can do that by calling java function like this
new File("/mnt/sdcard1/");

Where to put files for External Storage Android

So I have some files I want my Android App to access, read and write.
I want to store it internally. Where can I put these files in my Java Project so they are accessible or can this not be done?
There are three ways to achieve this, and according to your requirements select the approch
on SDCARD
This is the normal SDCARD/in-build SDCARD in newer smart phones. you need to create specific folder structure and put your files there, here you can do file read and write both
but this in insecure because accessible to all the application
on Internal Storage
This is given as Applicaiton specific storage where you can create the file and do the operation, this is most secure way to do it, but this is generated run time so you can not push the files directly, you can put your files in RAW or ASSETS and copy that here
RAW and ASSETS
This is in the code structure only and only read access is given to this folder, you can not change this file run time.
if you select any one of this approach then simple goggling will show you the sample code.
You can read or write files in the path of your internal storage as
data/data/package_name/files . I had already answered a similar question you can check it out.

Can i move a file in an asset folder to an asset sub-folder?

i have a file in the asset folder, and when i press a button in my program i have to move that file in a sub-folder(run-time). Can it be done?
i have to do this:
assets/file.txt -> assets/aaa/file.txt
No your assets are compiled into your apk file. Consider storing a persistent preference marking whatever you are trying to do instead.
No, you can't do it. You can't write anything inside the assets folder programmatically. Better option is to use internal storage. You can use Files Folder in the internal storage. See getFilesDir() in the docs.
Reason: Once you have an .apk file it is read only, so you can't add, delete or modify in it,
Alternate:
though you can use the sqlite DB for the purpose... where you can save file in hierarchy using blob type and you can modify it through queries...

Access data from Internet and update it into the file in Assests folder

Is it possible to access data from internet and update it into the file which is present in assets folder. If possible , please tell me the way to achieve this.....
You can't do that. The Assets folder is READONLY. Just copy the file to sd and use it from there. you can modify it however you want there.
Here is how you can access the file programatically.
And you can find some code on stack about saving files to SD there are tons of examples here. also don't forget setting the right permissions in the manifest.
For downloading files off the internet: downloadFiles
There are two questions in this: a)access data from the Internet. and b)update a file in assets folder. which one you want us to help you with?
Secondly, writing a file in assets folder isn't possible. Why do you want to do that!?
The answer of your first question is yes.If you want to parse data then you can parse.See this. Here you can parse comfortably from any kind of pages.
The answer of your second question is no.Why you want to save the data there.You have the device sdcard.You can save there.The folder(asset) is used by the android for the application's internal purpose

how to open Iphone's database(created) in Android?

Database is created in Iphone using SQLite.Now I want to use same database file in Android and insert the data into tables.How to do that?
Android Developer
The easiest way is to copy the file in your applications folder say assets folder and copy the database from the local file, first time the app is loading.
this link will give you a solution.

Categories

Resources