Trying to implement import and export feature in my application.Exporting is just copying of file in to the sd card. which i have done but importing is bit problematic. As importing should delete the previous rather the current database i am using and load the previous one.
I have gone through various post on this site regarding importing of sqlite database from sd card in application.Importing database,here there is an answer but i want to know when this method is to be called .? Or any other solution for this. would be really appreciated !
I feel this link will help you to find a solution basically you have to check whether you have included the permission in your manifest file to read and write external storage Device then follow the tutorial.
Refer this.. Using this you can club your db (.sqlite) in zip folder inside assests.
On installation it will unzip that & create the databse from your .sqlite file.
Related
I want to create a Directory like we have for whatsapp in my internal storage. I've checked path_providers but thats not exactly what I need.
I want to create a directory in our default internal storage where the Android, Downloads, Pictures are all present and store data to that folder.
As asked the path I need is /storage/emulated/0/MyFolder.
Please don't suggest path_providers or shared_preferences. I need to create a folder in the path where the File manager in our phone opens up.
Is it possible? If yes, please tell me how can I do it?
I got the answer to do this in Native Java
as
Environment.getExternalStoragePublicDirectory("myFolderName");
Just check if the directory already exists and create if not exists!
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/");
I am developing an app in android which consists of activities that need to connect to the Database . I added my database file in assets folder which gets copied over to applications database directory on first time the app runs but "assets" directory and "data" directory(on rooted devices) can be accessed by any other application . I'm confusing between using database file or create database in code . If i create database in code it make the database file disappear in the "assets" folder . When users change the file extension from .apk to .zip ,database file will not appear in assest folder . What I should to do ?
Please give me some advice !
Both ways are good and useful it completely depends on your need.
By creating database in code you can secure your data from other applications but it will take so much pain to create it in that way so i suggest you to use a db or sqlite file in assets folder and while copying database on device or data folder use some security parameters to encrypt it or you can hide your app database folder on device so other applications and users will be not able to access it easily.
Well keeping Database in assets folder is not at all a bad practice plus it saves coding of creating a database , as far as you want to make it secure you have to do 2 things
1.keep you database in assests folder , and copy and save it in the internal memory , now its available only to your application and delete it from assests folder .
2.Use Proguard to protect it from somebody decompiling your application and obtaining the assests.
And yea if its a confidential data in the application and your application is worth it then you can also go for "encrypting data" but yea its a TDS task , see for yourself what suits you now.
Honestly, this is the best explained and a very complete tutorial on the subject
SQLite Android Tutorial
Don't get repulsive, because it's a bit longer one. Everything is explained nicely and you don't have to do the thinking about the location of your asset folder on different devices and so on...
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
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