L leitor79 Active Member Licensed User Longtime User Mar 18, 2015 #1 Hi, I need to use a sqlite file on my app, and I'm not sure about the implementation since I've never used a database on an android app before. Would you recommend to create it within the app, if the file doesn't exist, or It's better to create it with some tool (sqlite database explorer), adding it into the files's project and be copied to the device upon development? If the last case is recommended; adding the file into the files's project will automatically make the file to be copied into the device? Where (file.dirrootinternal, etc?)? I need the file to be read/write, and not to be automatically deleted when the devices runs low on storage... Thank you very much!
Hi, I need to use a sqlite file on my app, and I'm not sure about the implementation since I've never used a database on an android app before. Would you recommend to create it within the app, if the file doesn't exist, or It's better to create it with some tool (sqlite database explorer), adding it into the files's project and be copied to the device upon development? If the last case is recommended; adding the file into the files's project will automatically make the file to be copied into the device? Where (file.dirrootinternal, etc?)? I need the file to be read/write, and not to be automatically deleted when the devices runs low on storage... Thank you very much!
E Eumel Active Member Licensed User Longtime User Mar 19, 2015 #2 You can make both. Create with code, or put in in the files folder. The second way, you must copy the db from "file.dirAssets" to the folder you need at Appstart. Code: If File.Exists(DBFileDir,DBFileName) = False Then File.Copy(File.DirAssets,DBFileName,DBFileDir,DBFileName) End If If your device has a sd card, you can copy it there. So test it with Code: If File.ExternalWritable = True Then DBFileDir = File.DirDefaultExternal Else DBFileDir = File.DirInternal End If ----------------- Eumel Upvote 0
You can make both. Create with code, or put in in the files folder. The second way, you must copy the db from "file.dirAssets" to the folder you need at Appstart. Code: If File.Exists(DBFileDir,DBFileName) = False Then File.Copy(File.DirAssets,DBFileName,DBFileDir,DBFileName) End If If your device has a sd card, you can copy it there. So test it with Code: If File.ExternalWritable = True Then DBFileDir = File.DirDefaultExternal Else DBFileDir = File.DirInternal End If ----------------- Eumel
L leitor79 Active Member Licensed User Longtime User Mar 19, 2015 #3 thank you very much, Eumel!!! Upvote 0