1

I think I may know the answer to this question already, but I just wanna be 100% sure. Anyways, I am writing an Android app using Eclipse 4.2 ("Juno"). I want to create my SQLite database by using external files and reading/parsing these files by my code. Hence, I created my own directory called /database and placed it in my project's root directory. Then, Eclipse starts complaining, reports a problem and says:

Invalid recourse directory name.

I even tried placing my database directory in the existing /res directory, but that caused the same Eclipse problem. Just want to confirm what my initial thoughts are: Is it not allowed for me to define my own directories in the project and bundle it in with my release?

If so, then I guess I'll have to follow along with what was posted in this stackoverflow question.

Community
  • 1
  • 1
ecbrodie
  • 11,246
  • 21
  • 71
  • 120
  • Why don't you want to use the default `/databases` folder? – Sam Sep 29 '12 at 22:58
  • Is there even a default /databases folder? – ecbrodie Sep 30 '12 at 01:34
  • 1
    I see what you are doing now. In Eclipse, you should store your database in `res/assets`. But the first time you run the app, move it to `/data/data//databases/`. I read your question as though you were trying to change the run-time location... – Sam Sep 30 '12 at 16:14

2 Answers2

2

put it in /assets not in /res and it should work.

edthethird
  • 6,263
  • 2
  • 24
  • 34
  • If I do so, will I be able to read from these files once my app is released and installed onto a device? I'm trying to determine whether I should create the database for the app at runtime (app reads SQL commands from the files) or before release (I package an embedded, precreated database file with the app). – ecbrodie Sep 30 '12 at 01:30
  • Nevermind! This link confirms that I can read directly from the assets directory: http://www.michenux.net/android-database-sqlite-creation-upgrade-245.html – ecbrodie Sep 30 '12 at 01:49
1

You should be able to create arbitrary directories in the root of your Android project, however your application won't be able to access these files. This is useful for development purposes like storing test data, documentation, or jar files. However, you cannot create non-standard directories in places like gen and res.

Eric Levine
  • 13,536
  • 5
  • 49
  • 49