8

I"m trying to Create a sample data directory, using Android Studio, by clicking on app in the project view and then right mouse click to find the menu item New > Sample Data Directory.

It is not working.

DoctorLouie
  • 2,699
  • 1
  • 18
  • 23
mcarmel90
  • 129
  • 1
  • 6

4 Answers4

7

Creating the directory via android studio doesn't always work. You may need to create the directory manually in your directory structure (at /app/sampledata/) without using Android Studio. Once you create it (e.g., via Windows Explorer) it should show up in Android Studio. See the the following answer for more information about sample data in general: How to put new placeholder resources into Android Studio project ("tools:sample" resources)?

"Unlike resources like images, fonts, etc. The sample data does not go in /res/ (they are not compiled with the app, hence. It is probably easier to filter them out by putting them in a totally separate directory). They go in /app/sampledata/, for example: /app/sampledata/image.png."

Shawn
  • 161
  • 1
  • 6
1

You can create a sample data directory in Android Studio itself by following the below steps:

  1. Change the view of directory structure from Android to Project as follows Screenshot 1 Screenshot 2 Screenshot 3

  2. Right click app folder and select New->Directory Screenshot 4

  3. Finally, give a name to your directory, in your case, it should be sampledata Screenshot 5

I have already created sampledata directory that's why it says "Directory already exists".

That's it. You have done it. Remember that Android Studio also supports loading sample data from a json file. All you have to give is fully qualified name of the key residing in the json file.

Ex- if your json file contains key name inside a Json Array student, then you have to specify it as "@sample/your_student_file.json/student/name" to use values present in key name.

Divya Gupta
  • 494
  • 8
  • 24
0

Unless your issue happens to be different, this is a known issue that only affects Windows. As I've found, it has something to do with 'C:\' in the file path.

https://issuetracker.google.com/issues/124553391

As Shawn mentioned, you need to manually create the directory.

I've been unable to get the images to actually display in the previewer, which I suspect may also be caused by the file path bug.

Pilot_51
  • 7,337
  • 3
  • 29
  • 26
0

Inside the app folder in file explorer, You can create a new folder (sample data) which will be reflected in your android studio.

Ms_Sri
  • 61
  • 1
  • 3